xargs and grep

Associate
Joined
1 Aug 2003
Posts
1,053
I wanted to grep -v a text file, but the file was too long, so I did the standard thing of piping to xargs grep, but the text file contains a list of file names and when piped to xargs, it tries to read the files rather than treating the output as text and running grep on the text - any suggestions?

My first thought was to use sed to insert something at the beginning of each line but was wondering if there was a simpler method.
 
Associate
Joined
7 Aug 2017
Posts
415
Location
location location
If you are trying to grep -v a large file that's >2.4G, why not split that file manually into smaller chunks and just grep -v those?

If you just xargs grep the list of filenames without giving grep a FILE of "-", I suspect grep will look for matches (or the inverse in this case) within each file rather than the std input text itself.
 
Associate
OP
Joined
1 Aug 2003
Posts
1,053
Turns out, there was no problem with running grep just from bash - the only thing in the text file that didn't match the string was the line 'too many arguments'..... it took me hours to figure that out, felt like such an idiot
 
Back
Top Bottom