Hassan HABIBI
Hassan HABIBI

Reputation: 21

Using sed, delete everything between two characters

How can I delete symbols, whitespaces, characters, words everything between two characters in a line?

My 5-line file is:

"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)" 120.94.30.12 264 556 -    
"Skype for Macintosh" 120.94.30.9 1038 482 -
-129.94.30.4 217 309 -
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)" 120.94.30.8 1197 747 -
"¢¢HttpClient" 120.94.30.12 594 231 -

I want to delete everything comes in between " and " (including the " characters) so that the required output should be:

120.94.30.12 264 556 -
120.94.30.9 1038 482 -
-120.94.30.4 217 309 -
120.94.30.8 1197 747 -
120.94.30.12 594 231 -

Upvotes: 2

Views: 13063

Answers (2)

Brian
Brian

Reputation: 2551

You mean like this?

sed 's/"[^"]*"//' file

Upvotes: 5

Summer_More_More_Tea
Summer_More_More_Tea

Reputation: 13356

 echo '"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1)" 120.94.30.12 264 556 -' |\
 sed -e 's/".*"\(.*\)/\1/g'

Upvotes: 1

Related Questions