Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-24-2010
Registered User
 

Join Date: Nov 2009
Posts: 78
Thanks: 13
Thanked 0 Times in 0 Posts
Help me using sed

Hi ,

I have this record as output of my script but i want it to filter more so as not to display those records/lines that has lesser than 10.

here is the sample record:


Code:
Feb 24 abraham     60.191.95.78  =  2
Feb 24 andrea     60.191.95.78  =  2
Feb 24 page     60.191.95.78  =  2
Feb 24 magenta     60.191.95.78  =  2
Feb 24 user     60.191.95.78  =  22
Feb 24 clemence     60.191.95.78  =  10
Feb 24 cvsroot     60.191.95.78  =  4
Feb 24 richard     210.83.161.213  =  2
Feb 24 kaitlyn     60.191.95.78  =  11
Feb 24 allan     60.191.95.78  =  2
Feb 24 guest     60.191.95.78  =  20
Feb 24 taylor     60.191.95.78  =  11
Feb 24 abigail     60.191.95.78  =  12
Feb 24 ana     60.191.95.78  =  10
Feb 24 jasmine     60.191.95.78  =  11
Feb 24 paulette     60.191.95.78  =  10
Feb 24 bind     60.191.95.78  =  2
Feb 24 squirrelmail     60.191.95.78  =  3
Feb 24 allison     60.191.95.78  =  40
Feb 24 cecile     60.191.95.78  =  20
Feb 24 nath     60.191.95.78  =  45
Feb 24 gamma     60.191.95.78  =  2
Feb 24 aaron     60.191.95.78  =  2
Feb 24 emma     60.191.95.78  =  11
Feb 24 love     60.191.95.78  =  2
Feb 24 avery     60.191.95.78  =  10
Feb 24 setup     75.73.173.60  =  2
Feb 24 joan     75.73.173.60  =  2
Feb 24 luce     60.191.95.78  =  10
Feb 24 alpha     60.191.95.78  =  2
Feb 24 chantal     60.191.95.78  =  110
Feb 24 horde     60.191.95.78  =  2
Feb 24 username     210.83.161.213  =  2
Feb 24 obelix     60.191.95.78  =  3
Feb 24 constance     60.191.95.78  =  15

Anyone can help me on this ?
Sponsored Links
    #2  
Old 02-24-2010
devtakh devtakh is offline Forum Advisor  
Unix Enthusiatic
 

Join Date: Oct 2007
Location: Bangalore
Posts: 730
Thanks: 0
Thanked 6 Times in 6 Posts
use awk:


Code:
awk '$NF>=10{print}' file

cheers,
Devaraj Takhellambam
Sponsored Links
    #3  
Old 02-24-2010
amitranjansahu's Avatar
Registered User
 

Join Date: Jan 2009
Location: Bangalore,INDIA
Posts: 503
Thanks: 4
Thanked 26 Times in 26 Posts

Code:
awk -F"=" '{if ( $2 <= 10 ) print $1 $2 }' filename

    #4  
Old 02-24-2010
Registered User
 

Join Date: Mar 2009
Posts: 175
Thanks: 0
Thanked 2 Times in 2 Posts

Code:
 sed -n '/\=\s*[0-9][0-9][0-9]*$/p' abc.txt

HTH,
PL
Sponsored Links
    #5  
Old 02-25-2010
vivekraj's Avatar
Registered User
 

Join Date: Feb 2010
Location: Chennai
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
We can also do the parsing by this way.

sed -nr '/\=\s*[0-9]{2,}$/p' <inputfilename>
Sponsored Links
    #6  
Old 02-25-2010
Registered User
 

Join Date: Nov 2009
Posts: 78
Thanks: 13
Thanked 0 Times in 0 Posts
Whew,

Thanks to all. I'll appreciate all your replies.

May i know how can I earn on this forum ?

Sponsored Links
    #7  
Old 02-25-2010
devtakh devtakh is offline Forum Advisor  
Unix Enthusiatic
 

Join Date: Oct 2007
Location: Bangalore
Posts: 730
Thanks: 0
Thanked 6 Times in 6 Posts
Did you mean learn or earn?
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -4. The time now is 12:52 AM.