Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: nariwithu
1,122
Posted By RudiC
This may work, at least on your simplified...
This may work, at least on your simplified samples:awk '/<AAAA>/,/<\/AAAA>/ {X=X"\n"$0} /<\/AAAA>/ && X ~ /123456789/ {print X; X=""}' file

<AAAA>
abc
<id>123456789</id>
ddd
</AAAA>
1,122
Posted By MadeInGermany
X should be cleared at the end of every block ...
X should be cleared at the end of every block
awk '/<AAAA>/,/<\/AAAA>/{X=X"\n"$0}
/<\/AAAA>/ {if (X~/123456789/) print X; X=""}' file
Forum: Solaris 12-07-2006
116,772
Posted By Ygor
Try...nawk...
Try...nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2 a=4 s="string" file1...where "b" and "a" are the number of lines to print before and after string "s".
...
2,612
Posted By mirni
This is not correct. These are three steps; you...
This is not correct. These are three steps; you have to run them one at a time:
./configurethen
makethen
make installAs for the garbled command... hmm... interesting. It is working ok, with my...
2,612
Posted By Scrutinizer
If there are no empty lines, you need something...
If there are no empty lines, you need something more complicated like this, or you can preprocess first like mirni suggested...
/usr/xpg4/bin/awk '$0~"<"resp{sect=1}
sect{p=p (p?RS:x) $0}
...
2,612
Posted By mirni
In your posted input, there is no 'response2',...
In your posted input, there is no 'response2', there is only 'reponse2'. Is this a typo, or is there really "reponse" in the input?
Showing results 1 to 6 of 6

 

Featured Tech Videos

All times are GMT -4. The time now is 04:35 PM.
Unix & Linux Forums Content Copyright 1993-2021. All Rights Reserved.
Privacy Policy