Any "sed" experts out there? Help required!

Associate
Joined
7 Jul 2009
Posts
510
Location
Bristol, UK
I was wondering if there are any "sed" experts out there. My skills are weak and Im having trouble creating an expression to do what I want.

I have a comma delimited line such as;

Code:
 a,b,c,d,"e,f,g,h",i,j,k,l,"m,n,o,p,q",s,t

I want to remove anything in-between and including the quote marks. Eg the result would be

Code:
 a,b,c,d,,i,j,k,l,,s,t

The double ,, is ideal for me.

I have the following sed command

Code:
 sed 's/".*"//g'

but this removes everything between the first " and last " giving me

Code:
  a,b,c,d,,s,t

Anybody got any ideas how I can achieve what Im after?

Cheers!
 
I have a comma delimited line such as;

Code:
 a,b,c,d,"e,f,g,h",i,j,k,l,"m,n,o,p,q",s,t

I want to remove anything in-between and including the quote marks. Eg the result would be

Code:
 a,b,c,d,,i,j,k,l,,s,t

Code:
$ echo 'a,b,c,d,"e,f,g,h",i,j,k,l,"m,n,o,p,q",s,t' | perl -p -e 's/".+?"//g;'
a,b,c,d,,i,j,k,l,,s,t

Perl :/
 
That will do the job lovely thanks! I forgot about perl. Sed doesnt like the non-gready ? and it was throwing me...

Cheers very much. Youve made my day much easier! :)
 
Back
Top Bottom