![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Unix Script to parse a CSV | RJ17 | Shell Programming and Scripting | 16 | 09-10-2008 11:07 PM |
| Need help in creating a Unix Script to parse xml file | Anil.Wmg | Shell Programming and Scripting | 10 | 07-29-2008 07:58 AM |
| Unix shell script to parse the contents of comma-separated file | KrishnaSaran | Shell Programming and Scripting | 11 | 06-20-2008 06:43 AM |
| How to parse through a file and based on condition form another output file | sivasu.india | UNIX for Advanced & Expert Users | 6 | 02-28-2008 04:59 AM |
| Parse Unix Mail | its-ashish | Shell Programming and Scripting | 4 | 01-18-2007 04:48 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to parse this file in unix
Hi all,
I need to parse a file which is having this format: Details: 1 Name{ first=james second=steven } Sibling{ first=2 second=3 } Age{ first=13 second=14 } Friend{ jessy } Details: 2 Name{ first=lily second=tracy } Sibling{ first=2 second=3 } Age{ first=13 second=14 } Hobby{ hobby1=swimming } The output is Name_first,Name_second,Sibling_first,Sibling_second,Age_first,Age_second,Friend,Hobby1 james,steven,2,3,13,14,jessy, lily,tracy,2,3,13,13,,swimming At first, I hardcode the header and use awk to retrieve the value line by line. e.g: A=`awk 'NR==3 { for(i=1;i<=NF;i++){ if ( $i == "first" ) { print $3 $4 } } }' file` However, the details: 1 and and details: 2 is different.Any idea on how to parse this file? Need it urgently. Thanks for help! |
|
|||||
|
I can't see your code ? How did you try it to use ? My code was only "proto", idea of parsing input and make output. Learning awk, not only cut&paste. Giving idea of scripting, in this case using awk. I think that in this forum we are waiting that you have basic knowledge from tool what you are using/asking helps.
Subject is "how to parse this file in unix", better subject is "how to parse this file using awk", if you like to know/learn solution using awk. Good subject help me( us ) to browse all subject and which are maybe for just for me. Too generally subjects make this "hoppy" hard - too much noice. Awk basic: Part 1 Part II Part III |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|