How to use > in an xargs command?
Posted
by jesse
on Stack Overflow
See other posts from Stack Overflow
or by jesse
Published on 2009-05-10T18:51:37Z
Indexed on
2010/06/10
18:33 UTC
Read the original article
Hit count: 272
I want to find a bash command that will let me grep every file in a directory and write the output of that grep to a separate file. My guess would have been to do something like this
ls -1 | xargs -I{} "grep ABC '{}' > '{}'.out"
but, as far as I know, xargs doesn't like the double-quotes. If I remove the double-quotes, however, then the command redirects the output of the entire command to a single file called '{}'.out instead of to a series of individual files.
Does anyone know of a way to do this using xargs? I just used this grep scenario as an example to illustrate my problem with xargs so any solutions that don't use xargs aren't as applicable for me.
© Stack Overflow or respective owner