I'm on Ubuntu. I copied some arguments (separated by newline) and I can use xsel to print them out like this
$ xsel
arg1
arg2
arg3
arg4
...
Now, I want to use each of these arguments for another command and execute that command as many times as there are arguments.
So I tried
$ xsel | mycommand "constantArgument" $1
However, this executed mycommand
only for the first argument. How can I execute it for every argument?
Best Answer
You can simply use
xargs
-n1
means one arg for mycommand, but it's just dry run, it will show what going to be run, to run it removeecho
For constant Argument