Thanks, I was looking for a way to add an argument at the end of the command. I could only find stuff about the -I option but that allows only one argument at a time. This bash way works great and allows me to only type my password the minimum number of times when copying a lot of files.
The only change is that you should quote the arguments to properly handle arguments with spaces.
You may think that quoting the $@ would make it be treated as one argument but bash has a convenient special case. From the bash man page: "When the expansion occurs within double quotes, each parameter expands to a separate word."
Thanks, I was looking for a way to add an argument at the end of the command. I could only find stuff about the -I option but that allows only one argument at a time. This bash way works great and allows me to only type my password the minimum number of times when copying a lot of files.
The only change is that you should quote the arguments to properly handle arguments with spaces.
ls -1 *.jpg | xargs -d "\n" -P 4 -n 8 -- bash -c 'scp "$0" "$@" dad@garages:images/'
You may think that quoting the $@ would make it be treated as one argument but bash has a convenient special case. From the bash man page: "When the expansion occurs within double quotes, each parameter expands to a separate word."
Hope that helps someone.