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 a csv file chiru_h Shell Programming and Scripting 6 02-12-2008 09:33 AM
Sometimes ancient myths kill computers - Ventura County Star iBot UNIX and Linux RSS News 0 09-03-2007 12:00 PM
parsing file through awk bbeugie Shell Programming and Scripting 13 08-22-2006 02:21 PM
Parsing a Log file tbirenzweig Shell Programming and Scripting 4 06-20-2006 08:02 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 Rate Thread Display Modes
  #1 (permalink)  
Old 08-03-2006
mike@freddiemac mike@freddiemac is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 5
Question parsing a STAR tag-value file

I have a recent file I am trying to parse that looks like this:

value_one:1:value_two:2:value_three:3

value_one matches to 1
value_two matches to 2
value_three matches to 3


the semi-colons not only seperate the tags to their corresponding values, but also seperate tag/value pairs from one another

is there anyway to parse this file so that I can get an output that looks like this:

1
2
3


and also another output that looks like this:

value_one
value_two
value_three



any help appreciated
  #2 (permalink)  
Old 08-03-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,411
Try...
Code:
$ awk -v RS=: 'NR%2==0' file1
1
2
3

$ awk -v RS=: 'NR%2==1' file1
value_one
value_two
value_three

  #3 (permalink)  
Old 08-03-2006
mike@freddiemac mike@freddiemac is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 5
that worked very well...can you explain NR%2==0 term...and also how do i get rid of the extra new line at the end???
Closed Thread

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 09:36 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