Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete all lines with (....)

Status
Not open for further replies.

kukuluku

MIS
May 2, 2002
56
US
Hello,

I have a file which contains something like:

STORAGE(INITIAL 50380800 NEXT 8388608 MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL
DEFAULT) TABLESPACE "PS_MEDIUM" ;

I need to remove everything starting from STORAGE to ")".

I was thinking to use sed 's/STORAGE\(.*\)//g but this only delete from STORAGE to end of the line which is MAXEXTENTS in this case.

Is there any way to have this done?

Thanks!
 

This awk program assumes there is only one closing parenthesis on a line. You'll have to improve the regex in the gsub's if there can be more.

/STORAGE\(/ {
if ($0 ~ /\)/) {
gsub(/STORAGE.*\)/,"")
print
next
}
while (getline > 0 && $0 !~ /\)/) ;
gsub(/.*\)/,"")
print
next
}
{ print }

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
put in sedcmd
--------------------------
/)/a
/STORAGE(/,/)/d
--------------------------

the sed -f sedcmd filename, nota the empty-line NEEDED
UNTESTED
sed -e '/STORAGE/,/)/' sure works but kills also
TABLESPACE "PS_MEDIUM" ;


why not

sed -ne 's/.*)\(.*\)/\1/p' filename

this print ONLY strings after an ')'

 
I don't quite get this. Can you please list the whole syntex?

Thanks a bunch,
 
For my solution, put the code into a file ku.awk, say and enter

awk -f ku.awk infile > outfile

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top