[SATLUG] xargs question(s)

Don Davis dondavis at reglue.org
Mon Aug 27 09:21:20 CDT 2012


Question:

cat remove_from_list_* |tr "\//" "."| xargs -I {} sed -i "s/{}$//g"
get_these_batch


Is more equivalent to:
for file in $(cat remove_from_list_*) |do sed -i "s/$(echo "$file"| tr
"\//" ".")$//g" get_these_files.list

Than:
for file in $(cat remove_from_list_*) |do sed -i "s/$(echo "$file"| tr
"\//" ".").*$//g" get_these_files.list

#I used dots because the picket fences weren't working out well...


Correct?

The question is basically is {}$ more like \1$ or \1.*$ for some reason?


So if remove_from_list has:
apple
banana
cherry

And get_these_files.list has:
apple_pie
bananasplit
cherry

Then only cherry will be removed with the xargs command above - ?


About the workings of xargs - I noticed a substantive performance
difference in the command above and a similar command using xargs vs.
find & do. My thought is that with find everything gets pulled into
working memory first and then iterated through - whereas xargs somehow
does something differently. ?

I apologize that I tacked question marks on to so many sentences to make
questions.



More information about the SATLUG mailing list