The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
subtitute specific column in line MomoChan Shell Programming and Scripting 11 08-26-2008 03:28 AM
oneliner:sing SED on a specific column chaseeem Shell Programming and Scripting 8 07-15-2008 07:10 AM
How to extract first column with a specific character selamba_warrior Shell Programming and Scripting 3 05-22-2008 06:14 AM
How to read a specific column into variable victorcheung Shell Programming and Scripting 2 04-18-2008 02:49 AM
Adding blank white sapce at specific column Jae Shell Programming and Scripting 6 08-08-2007 09:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 09-02-2008
kmaq7621 kmaq7621 is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 3
how do i parse by specific column?

I have a log file with 13 columns. The 12th column contains the status code (example 200, 404, 500, 403, etc.) I want to remove all 200 status lines. so...

1. remove all the lines in which the 12th column has a 200.
2. display only the lines in which the 12th column shows a 500.

Thanks.
  #2 (permalink)  
Old 09-02-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,441

Code:
awk '$12!=200' file
awk '$12==500' file


Last edited by danmero; 09-02-2008 at 10:20 PM.. Reason: add solution for (1)
  #3 (permalink)  
Old 09-02-2008
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
Quote:
Originally Posted by kmaq7621 View Post
I have a log file with 13 columns. The 12th column contains the status code (example 200, 404, 500, 403, etc.) I want to remove all 200 status lines. so...

1. remove all the lines in which the 12th column has a 200.
2. display only the lines in which the 12th column shows a 500.

Thanks.
perl -ane 'print unless $F[11] eq "200"' temp.txt
perl -ane 'print if $F[11] eq "500"' temp.txt

Note: The -a flag to Perl is "auto-split," which creates an array named F which you can then address by element.
Closed Thread

Bookmarks

Tags
sed awk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0