Quote:
Originally Posted by pixellany
You haven't answered my other questions---including why it has to be Awk.
For the solution you posted, what was the problem?
Here something in SED, but not completely tested:
Code:
sed '/#/{h;n;/pattern/{d;g;d}};/pattern/d' filename > newfilename
|
I tried using it.. but its not working.
The answer for your question why in awk is I tried with SED but couldnt get the exact command. So I thought it can be done using awk.
Some thing like below I got it now using nwak.
nawk -v pattern=$pattern '/^#/ {printf line; line=$0"\n"; next} $0 ~ pattern {line=""} $0 !~ pattern {printf line; print; lin
e=""}' $filename
it seems it is working now. Doing the complete testing.