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
Help me with parsing this file eamani_sun Shell Programming and Scripting 2 05-16-2008 04:39 PM
Parsing xml file using Sed kapilkinha UNIX for Advanced & Expert Users 3 04-08-2008 10:43 AM
Parsing a csv file chiru_h Shell Programming and Scripting 6 02-12-2008 09:33 AM
File Parsing jsusheel Shell Programming and Scripting 5 09-25-2007 11:25 AM
parsing file through awk bbeugie Shell Programming and Scripting 13 08-22-2006 02:21 PM

 
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 Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-06-2008
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
awk and file parsing

Hi, I have a input file like this

TH2TH2867Y NOW33332106Yo You Baby
TH2TH3867Y NOW33332106No Way Out
TH2TH9867Y NOW33332106Can't find it
TJ2TJ2872N WOW33332017sure thing alas
TJ2TJ3872N WOW33332017the sky rocks
TJ2TJ4872N WOW33332017nothing else matters
TJ2TJ5872N WOW33332017you know about it
TJ2TJ6872N WOW33331999nothing else matters
TJ2TJ7872N WOW33332017nothing else matters
TJ2TJ8872N WOW33332017No Way Out
TJ2TAW872N WOW33331999No Way Out
TJAPXC050Y NOW33331999No Way Out.
TJAT1N999Y NOW33331999still loving you.
TJBJOG575Y NOW33331999Jacka nd jill.
TJBJXG575Y NOW33331999Julie and friend

I am trying to get the output something like this-

Yo You Baby|TH2
No Way Out|TJ2
still loving you.|TJA
You got it|TJB

Here..TH2,TJ2,TJA and TJB are the distinct first 3 characters from the input.
In the input , lets say fr=substr($0,1,3) and nx=substr($0,4,3).
Basically, i want to check the line if the first 3 character(fr) = the next 3 characters(nx), then print substr($0,23,20) and the substr($0,1,3)

If they dont match, then print the first occurance of the fr with the substr($0,23,20).

Help!

Regards,
Big Gun
 

Bookmarks

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 05:45 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