1855422 Members
17822 Online
104110 Solutions
New Discussion

How do I use grep?

 

How do I use grep?

Hi!
I want to get text lines from a file. This file conteints lines with several text line types.

How do I filter these lines using grep with logic "OR"?

Thank You!
Christian Aguilar
7 REPLIES 7
Uday_S_Ankolekar
Honored Contributor

Re: How do I use grep?

use

grep LTVCL text.log

and if you do not want NTVCL
then use
grep LTVCL text.log | grep -v NTVCL

-USA..
Good Luck..
Pete Randall
Outstanding Contributor

Re: How do I use grep?

Use sort:

sort text.log



Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: How do I use grep?

Hi:

# grep -e pattern1 -e pattern2 filename

As many '-e pattern' repetions as you want can be specified.

Regards!

...JRF...
Michael Steele_2
Honored Contributor

Re: How do I use grep?

grep -e LTVCL -e NTVCL | sort -n > /tmp/file

-or-

cat /tmp/file | sort -n > /tmp/file2
Support Fatherhood - Stop Family Law
harry d brown jr
Honored Contributor

Re: How do I use grep?


From your output, it looks like you really want to sort:

sort -t"-" -k1.1,1.5 -k2n -k3n -k4n -k5n fileNAMEhere


live free or die
harry
Live Free or Die
John Meissner
Esteemed Contributor

Re: How do I use grep?

man grep

grep data1

egrep 'data1|data2'
All paths lead to destiny
H.Merijn Brand (procura
Honored Contributor

Re: How do I use grep?

You said *any* command:

# perl -le'$,="-";print unpack"A5s4",$_ for sort map{pack"A5s4",split/-/}<>' infile

Well, it's easy once you understand it :) and it's still a one-liner (which probably can be even shorter)

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn