One option would be to use read
:
echo "arg3 arg1 arg2" | { read -r a b c; some_command ...; }
Now you can use arguments "$a"
, "$b"
and "$c"
as you wish.
I guess your example is a bit artificial but you can avoid a pipeline in this case:
{ read -r a b c; some_command ...; } <<< "arg3 arg1 arg2"
If the arguments really come from a command, then you can use a command substitution:
{ read -r a b c; some_command ...; } < <(command_producing_arguments)
Note that the semicolon at the end is important, if the command group { }
is written all on one line.