![]() |
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 |
| Parsing of file for Report Generation (String parsing and splitting) | umar.shaikh | Shell Programming and Scripting | 8 | 03-02-2009 01:38 AM |
| Parsing file, yaml file? Extracting specific sections | Rhije | Shell Programming and Scripting | 3 | 01-22-2009 06:36 PM |
| Script for parsing details in a log file to a seperate file | pingnagan | UNIX for Dummies Questions & Answers | 2 | 11-13-2008 12:21 PM |
| need help in Parsing a CSV file and generate a new output file | vkr | Shell Programming and Scripting | 15 | 08-01-2008 08:33 AM |
| Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names | nikosey | Shell Programming and Scripting | 6 | 07-30-2008 10:46 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Parsing a file
Hi,
I have a file that looks like this: Code:
>JANE:BOB_JOE.6 ELLEN, Barg c452 5691-6524 YINKHJHJHJGJGHGHGHGHGMNJHJHKJKJHJHJHJHJHJHJHJHJHJHJHJHJ >JANE:BOB_JOE.6 DOOR, Yak c459 5691-6524 REVERSE YINKHJHJHJGJGHGHGHGHGMNJHJHKJKJHJHJHJHJHJHJHJHJHJHJHJHJIIIIIIIIIIIIIIIIIIIIII Basically I only want it to print ELLEN, Barg c452 5691-6524 and DOOR, Yak c459 5691-6524 REVERSE into a seperate file. Phil Last edited by vgersh99; 07-20-2009 at 04:44 PM.. Reason: code tags, PLEASE! |
|
||||
|
Quote:
Code:
awk '/^>/ print {$2,$3,$4,$5,$6}' myfile
|
|
|||||
|
And here's a solution in Perl -
Code:
$ $ cat data.txt >JANE:BOB_JOE.6 ELLEN, Barg c452 5691-6524 YINKHJHJHJGJGHGHGHGHGMNJHJHKJKJHJHJHJHJHJHJHJHJHJHJHJHJ >JANE:BOB_JOE.6 DOOR, Yak c459 5691-6524 REVERSE YINKHJHJHJGJGHGHGHGHGMNJHJHKJKJHJHJHJHJHJHJHJHJHJHJHJHJIIIIIIIIIIIIIIIIIIIIII $ $ perl -lne '/^>[^ ]+ (.*)/ && print $1' data.txt ELLEN, Barg c452 5691-6524 DOOR, Yak c459 5691-6524 REVERSE $ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|