Reputation: 39
i want to replace special string using sed but how to disable special characeter functionality.
%D/%M/%Y %H:%I:%S,%F000
want to replace with %d/%m/%y %H:%i:%s,%f000
sed -i '/s\b%D/%M/%Y %H:%I:%S,%F000\b/%d/%m/%y %H:%i:%s,%f000/g' inputfile.txt
Upvotes: 0
Views: 227
Reputation: 2337
I found 2 issues in your sed
command:
You have placed s
after delimiter (/
). The search command s
should be before delimiter.
Your search pattern contains forward slash and you have used the
same as your delimiter which will create issues. sed
can use
variety of delimiters apart from widely used forward slash. Refer -
what-delimiters-can-you-use-in-sed
After fixing both, here is the updated sed
command (i have used !
as delimiter):
sed -i 's!%D/%M/%Y %H:%I:%S,%F000!%d/%m/%y %H:%i:%s,%f000!g' inputfile.txt
Upvotes: 1