How to print with awk specific field different from specific character? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

How to print with awk specific field different from specific character?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-22-2013
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
How to print with awk specific field different from specific character?

Hello,

i need help with awk.
I have this file:


Code:
cat number
DirB    port    67      er_enc_out      0       er_bad_os       0
DirB    port    71      er_enc_out      56       er_bad_os       0
DirB    port    74      er_enc_out      0       er_bad_os       0
DirB    port    75      er_enc_out      0       er_bad_os       45
DirB    port    76      er_enc_out      0       er_bad_os       0
DirB    port    77      er_enc_out      0       er_bad_os       0
DirB    port    78      er_enc_out      12       er_bad_os       0
DirB    port    79      er_enc_out      0       er_bad_os       0
DirB    port    202     er_enc_out      0       er_bad_os       0
DirB    port    203     er_enc_out      0       er_bad_os       19
DirB    port    204     er_enc_out      0       er_bad_os       0
DirB    port    206     er_enc_out      4       er_bad_os       6
DirB    port    207     er_enc_out      0       er_bad_os       0
DirB    port    96      er_enc_out      0       er_bad_os       0

I need to intercept the value different from 0. like this:

DirB port 71 er_enc_out 56 er_bad_os 0
DirB port 75 er_enc_out 0 er_bad_os 45
DirB port 78 er_enc_out 12 er_bad_os 0
DirB port 203 er_enc_out 0 er_bad_os 19
DirB port 206 er_enc_out 4 er_bad_os 6

thanks
Luca
Sponsored Links
    #2  
Old 08-22-2013
rdcwayx rdcwayx is offline Forum Advisor  
Use nawk in Solaris
 
Join Date: Jun 2006
Last Activity: 22 March 2014, 12:27 PM EDT
Posts: 2,759
Thanks: 44
Thanked 418 Times in 406 Posts

Code:
awk '$5!="0"||$7!="0"' number

Sponsored Links
    #3  
Old 08-22-2013
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
no, i'm sorry, i need to remove the line with this field:

er_enc_out 0 er_bad_os 0
    #4  
Old 08-22-2013
rdcwayx rdcwayx is offline Forum Advisor  
Use nawk in Solaris
 
Join Date: Jun 2006
Last Activity: 22 March 2014, 12:27 PM EDT
Posts: 2,759
Thanks: 44
Thanked 418 Times in 406 Posts
I get the answer same as in your first post.

Code:
awk '$5!="0"||$7!="0"' number

DirB    port    71      er_enc_out      56       er_bad_os       0
DirB    port    75      er_enc_out      0       er_bad_os       45
DirB    port    78      er_enc_out      12       er_bad_os       0
DirB    port    203     er_enc_out      0       er_bad_os       19
DirB    port    206     er_enc_out      4       er_bad_os       6

If you get difference, please try with nawk or /usr/xpg4/bin/awk.
Sponsored Links
    #5  
Old 08-22-2013
elilmal elilmal is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 27 August 2013, 8:27 AM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
thanks
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Print Specific lines when found specific character attila Shell Programming and Scripting 4 01-26-2012 04:33 AM
Replace specific field on specific line sed or awk crownedzero Shell Programming and Scripting 14 11-27-2011 03:34 PM
Using awk to read a specific line and a specific field on that line. Bungkai Shell Programming and Scripting 6 07-31-2011 01:13 PM
AWK Print Line If Specific Character Is Matched PointyWombat Shell Programming and Scripting 3 01-27-2011 04:32 AM
How to append a character to the last but one field on a specific line? npatwardhan Shell Programming and Scripting 2 02-03-2010 07:30 PM



All times are GMT -4. The time now is 08:19 PM.