![]() |
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 |
| no options | nascimento.rp | AIX | 2 | 08-20-2006 03:46 PM |
| options | terms5 | UNIX for Dummies Questions & Answers | 1 | 01-27-2006 01:50 AM |
| options with awk | mips | Shell Programming and Scripting | 2 | 05-15-2004 04:33 AM |
| cat and wc options | Laura01 | Shell Programming and Scripting | 1 | 09-09-2002 12:21 AM |
| cp options | milage | UNIX for Dummies Questions & Answers | 3 | 07-13-2001 01:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi ..
Happy New Year.. If i do a sed -e ' /BEGIN/,/END/{ h /xxx/{ g p } } ' temp1 I have two queries in this script 1.Will the block between BEGIN and END be stored in the hold buffer before executing the /xxx/ .. 2.When will /xxx/ be executed ..( Is it after one full block between BEGIN and END is completed ?) temp1 looks like BEGIN sdfdsf sdfsdf xxx END BEGIN sdfdsf sdfsdf END Thanks..Siva |
|
||||
|
sed h and g options
Yes I tested it myself ..
My objective is to take the block which has only xxx in it But it gives output like BEGIN sdfdsf sdfsdf xxx xxx END BEGIN sdfdsf sdfsdf END .. I am pretty new to sed .. may be my script has some basic error .. please help |
|
|||||
|
This looks fine.. It makes use sed's advanced flow control commands
Code:
[/tmp]$ cat 1
BEGIN
sdfdsf
sdfsdf
xxx
END
BEGIN
sdfdsf
sdfsdf
END
[/tmp]$ sed -n -e '/BEGIN/{
:top
N
/END/b end
b top
:end
s_.*xxx.*_&_p
}' 1
BEGIN
sdfdsf
sdfsdf
xxx
END
[/tmp]$
Code:
sed -n -e '/BEGIN/{
:top
/END/!{
N;
b top
}
s_.*xxx.*_&_p
}' 1
Vino Last edited by vino; 01-18-2006 at 04:39 AM.. |
|
||||
|
Thanks Vino
It works .. But what if I need the block with two patterns in it ..( the order of occurence of the pattern is not known .. Could you help me do this using hold and get options in sed .. I am a beginner in sed and I would love to learn using h and g options .. ( as I had asked in my original question .. /BEGIN,/END/h .. will the block be stored in hold space ??) Thanks Siva |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|