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
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
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