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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting a sed comande to awk

Status
Not open for further replies.

Darshh

Programmer
Mar 13, 2008
2
FR
hi,

i'm using this sed comande sed 's/"[^"]*"//g;s/#.*//' to

parse data file .

ex. data file :
"unwanted data" data
"unwanted data" data"unwanted data" #unwanted data
#unwanted data"unwanted data"
"#unwanted data" data#unwanted data

this sed comande takes out evrything between Double Quote and after #.

has anyone an idea on how to make the same in awk or nawk?

thanks Darshh
 
In the awk man page have a look at the gsub function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

this what i wrote but still there is a small problem, it doesn't erase the data betwen " " if this one starts on a line and finish on a 2nd line :

ex data:

data data "data unwanted
data unwanted " data data # data unwanted

awk '{ gsub(/"[^"]*"/, ""); print }' /data.log | awk '{ gsub(/#.*/, ""); print }'

thanks for your help.
 
How did you handle this situation with sed ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top