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

Deleting text between quotes 2

Status
Not open for further replies.
Apr 13, 2004
316
US
I couldn't find in my sed one-liners, but how do you delete text between quotes, for example:

this is "a test" of sed.

I want this to be left as:

this is "" of sed.

Thanks!!
 
assuming no 'embedded" quotes:

echo '"a test" ' | sed -e 's/"\([^"]*\)"/\1/g'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
sorry - misread what you wanted:

echo '1"a test"2' | sed -e 's/\("\)[^"]*\("\)/\1\2/g'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
No need to backward reference:
sed -e 's!"[^"]*"!""!g'

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top