Thursday, August 27, 2009

Nice trick with xargs

ls | xargs  -t -I{} echo {} {}.new

 

-t echo the command that is going to get executed before executing

-I{} Insert a new line where{} appears

 

e.g.

 

$ ls

first.txt  second.txt

 

$ ls | xargs  -t -I{} echo {} {}.new

echo first.txt first.txt.new

first.txt first.txt.new

echo second.txt second.txt.new

second.txt second.txt.new

No comments: