LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to filter lines (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-filter-lines-716072/)

Nortekman 04-01-2009 10:09 AM

How to filter lines
 
What is the command to filter lines that have a certain "strings" in a file?

druuna 04-01-2009 10:16 AM

Hi,

Filter as in remove or as in show?

grep -v "whatever" infile -> removes all lines that contain whatever

grep "whatever" infile -> show all lines that contain whatever

Hope this helps.

Nortekman 04-01-2009 10:32 AM

Quote:

Originally Posted by druuna (Post 3495014)
Hi,

Filter as in remove or as in show?

grep -v "whatever" infile -> removes all lines that contain whatever

grep "whatever" infile -> show all lines that contain whatever

Hope this helps.

Thanks for your help druuna, that helped a lot!

pixellany 04-01-2009 10:35 AM

Many utilities will do this---not just grep.

I suggest two references:
Bash Guide for Beginners--free at http://tldp.org

Classic Shell Scripting from O'Reilly --Any large bookstore, Amazon, etc.


All times are GMT -5. The time now is 10:41 AM.