The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
extraction of last but one char hidnana Shell Programming and Scripting 5 02-14-2008 08:22 AM
AWK extraction harris2107 Shell Programming and Scripting 3 08-17-2007 06:02 AM
Help with tar extraction! manthasirisha Shell Programming and Scripting 4 03-17-2006 07:17 AM
extraction from a tape big123456 UNIX for Advanced & Expert Users 4 10-25-2005 05:34 AM
help on file extraction apalex UNIX for Dummies Questions & Answers 1 05-01-2001 11:29 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 01-15-2008
harris2107 harris2107 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 8
AWK extraction

Hi all,
I have a data file from which i would like to extract only certain fields, which are not adjacent to each other. Following is the format of data file (data.txt) that i have, which has about 6 fields delimited by "|"

HARRIS|23|IT|PROGRAMMER|CHICAGO|EMP
JOHN|35|IT|JAVA|NY|CON
CHRIS|45|HR|ACCOUNT|NJ|EMP
JUDY|32|HR|RECRUIT||EMP

As you can see, there are 6 fields delimited by "|". All i want from this file are the 1,3,5,6 fields separated by the "|" delimiter. So, after extraction, i would like the file to look as

HARRIS|IT|CHICAGO|EMP
JOHN|IT|NY|CON
CHRIS|HR|NJ|EMP
JUDY|HR||EMP

How can i do this using AWK? or which ever utility that would help to achieve this? Remember there can be a null value in the field as could be seen in the last line of the file.

Any help would be greatly appreciated.

Thanks,
Harris.
 

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 10:23 PM.


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