Friday, June 27, 2008

xargs command replace string

Using xargs command with replace string

to scp files with spec pattern

ls file* | xargs -n1 -i{} scp {} root@:/dest

1 comment:

  1. I know I can pass the pattern to the scp command itself. But here the usage is for explaining the xargs command. In practical usage I replace scp with my own autocopy script. Autocopy script does not need me to give the password. But unlikely it is not that smart with the regex pattern. Then xargs comes handy to me to pass each filename to the Autocopy script in place of regex pattern.

    ReplyDelete