Reputation: 1927
I am trying to replace all strings in a line which match the pattern .*q=
or HTTP
with empty string.
I am using the below command for the same.
sed s/.\*q=\|HTTP.*//
But this doesn't work. It doesn't replace the string with the empty string. Can you please let me know if there is anything wrong with the above command.
Upvotes: 0
Views: 303
Reputation: 195239
this line should work for your requirement:
sed s'/\.\*q=\|HTTP//g'
for example:
kent$ echo "leave.*q=justHTTP foo"|sed s'/\.\*q=\|HTTP//g'
leavejust foo
your command:
g
flag in your s/../../
HTTP
you should not add .*
at the end of it, otherwise it will remove all string after HTTP inclusively. .*
, you need escape .
and *
Upvotes: 3