Reputation: 30990
trying to replace within a file everything including password up to the space.
password=xx%40%25PKz3L2jTa HTTP
tried the following sed command, using regular expression from http://en.wikipedia.org/wiki/Regular_expression
sed 's/password=(.)+/ /g' $file
and
sed 's/password=[^ ]+/ /g' $file
none of the above works. why?
Upvotes: 0
Views: 359
Reputation: 25537
The standard sed
does not understand "extended" regular expression, such as '+'. Two alternatives for you:
Enable extended regular expressions with
sed -E 's/password=[^ ]+/ /g' $file
or use standard regular expressions
sed 's/password=[^ ]*/ /g' $file
I prefer the second one because it is more portable and, unlike the first one, it will work with an empty password field.
Upvotes: 0