xargs

Xargs is a really useful command however it is also a little strange

Usually I use it like this

tim1
tim2
tim3

So to copy all these files I would do something like

cat files.txt | xargs -i -t cp {} /some/place/drive

Using The same parameter

I needed to use the same parameter and so I used this combination

cat file.txt | xargs -i -I {} echo 'html2text http:/tim.com/index.php/{} > md/{}'.md'' | bash

Mac

Of course this is a little different !!! Stupid Mac (at times)

the command now becomes

ls -l | grep tim | xargs -I {} lp {}

The -I {} tells the xargs command that this will be the substitution variable. It is implied in most other Unix-OS

Files which have Spaces in them

Modify the grep and the xargs

find . -name "*.bak" -print0 | xargs -0 -I file mv file ~/old.files

The -0 generally helps with the -print0