![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| extract x lines after a pattern - place each result in separate file | gobi | Shell Programming and Scripting | 5 | 06-06-2008 12:03 PM |
| extract field of characters after a specific pattern - using UNIX shell script | jansat | HP-UX | 2 | 05-27-2008 09:08 PM |
| nawk-how count the number of occurances of a pattern, when don't know the pattern | cyber111 | Shell Programming and Scripting | 2 | 05-11-2008 12:00 AM |
| Breaking output for specific pattern | shoeb_syed | UNIX for Dummies Questions & Answers | 2 | 03-08-2006 01:00 AM |
| Finding a specific pattern from thousands of files ???? | aarora_98 | Shell Programming and Scripting | 6 | 02-17-2006 05:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
to separate a specific pattern
Hi friends,
I have a file with following pattern. OBJECT TYPE="locale", NAME=locale_nl_NL, UNIQUE_FIELD=win32_lcid FIELDS clarify_lang = 0; END_FIELDS END_OBJECT NAME=locale_nl_NL OBJECT TYPE="locale", NAME=locale_nl_BE UNIQUE_FIELD=win32_lcid FIELDS iso_cntry = "BE"; END_FIELDS END_OBJECT NAME=locale_nl_BE I want to saparate lines starting with OBJECT till FIELDS. e.g. My o/p file should look like OBJECT TYPE="locale", NAME=locale_nl_NL, UNIQUE_FIELD=win32_lcid OBJECT TYPE="locale", NAME=locale_nl_BE UNIQUE_FIELD=win32_lcid How this can be done using perl/awk/sed?? thanks in advance, -Ashish |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -n -e '/OBJECT TYPE/{N;p}' input.txt
|
|
#3
|
|||
|
|||
|
I found follwing command useful for this.
$awk '/OBJECT *TYPE/,/FIELDS/' test.dat|grep -v FIELDS any better, neat answers?? |
|
#4
|
|||
|
|||
|
Vino,
seems some syntax problem with sed. $ sed -n -e '/OBJECT TYPE/{N;p}' test1.dat sed: command garbled: /OBJECT TYPE/{N;p} $ |
|
#5
|
||||
|
||||
|
Quote:
Code:
sed -n -e "/OBJECT TYPE/{N;p}" test1.dat
|
|
#6
|
|||
|
|||
|
vino ,
same problem. Quote:
|
|
#7
|
||||
|
||||
|
Post the results of uname -a I guess it must be something with your sed.
Try this. sed -n -e "/OBJECT TYPE/p" -e "/UNIQUE_FIELD/p" input.txt |
||||
| Google The UNIX and Linux Forums |