I'm trying to learn how to manipulate pipe flow using xargs. Often times I need the output of my commands to be fed into commands that can't be piped into by stdout.
awk seems to have some equivalent to represent the entirety of standard out with the symbol $0 when you print with it, and $1,$2 etc are individual fields, but I can't seem to find the equivalent in xargs anywhere.
Example: Something like this: standard out is a list of arguments that are out of order:
secondfield firstfield thirdfield secondfield2 firstfield2 thirdfield2 secondfield3 firstfield3 thirdfield3
I want to run pseudocode that looks like this:
cat file.txt | xargs myprogram $2 $1 $3
myprogram takes input fields in order where it should be the firstfield, secondfield, then thirdfield, but clearly my stdout is out of order. $1 $2 $3 only exist in awk. What is the equivalent?
(This is just a simplified example, but the point is that I need to know how to order my standard out stream into xargs in case I need to manipulate which varialbes go where in other complicated commands (mv for instance)