How to search for a file with a pattern that has a space in linux
I am struggling, which is why you need your help (on Linux).
a) I have a file with two columns separated by a space (the delimiter is ""). Infact, I run a series of piped commands on the command line that give me the output as above.
aaa bbb ccc ddd fff ggg ccc nnn fff kkk # there are approx 20,000 such rows.
b) I have many other files like file-1.txt, file-2. txt, file-3.txt.
Problem: I need to find every line in the output given in section a. higher. To illustrate, I want to run the equivalent:
grep 'aaa bbb' file-1 txt file-2.txt file-3 txt
grep 'ccc ddd' file-1 txt file-2.txt file-3 txt
......
20,000 times
.......
But the above command takes a long time.
Question:
How to use one command to perform this operation. Whenever I run the command (as shown below), the system only looks for single words in the string, for example for aaa and bbb, and gives me wrong output.
eg:
cat < filename > | cut -d "," -f1,2 | xargs -I {} sed '{}' file-1.txt
or using grep instead of sed ....
NOTE: the command before the pipe outputs the output in space, as indicated in point a. higher.
Any help would be much appreciated.
source to share