Saturday, November 8, 2008

linux:shell:bash:grep: multi-grep

If I want to search multi words by grep, I could do in the way:

egrep "a|b|c|d" my_input_file.txt

then egrep will help you to search OR of a, b, c and d. If searching for AND of multi-words, you can do by pipe:

grep a my_input_file.txt |grep b |grep c |grep d

. However, sometimes, it is not so easy to use pipe in one line for the above usage. You can always build string of the command first and evaluate it. For example,

cmd="grep $var1 my_input_file.txt|grep $var2"
...
cmd="$cmd |grep $var3"
...
eval $cmd

2 comments:

ICS Cyber Security said...

Might I also suggest that you try Inkscape as well. I just used it and it worked smoothly. Open the two pages then do a copy and paste from one to the other. Again, it only works for one page so you might need to do the PDF merge if you want multiple pages.

ICS Cyber Security said...

Might I also suggest that you try Inkscape as well. I just used it and it worked smoothly. Open the two pages then do a copy and paste from one to the other. Again, it only works for one page so you might need to do the PDF merge if you want multiple pages.
PDF signature


Locations of visitors to this page