we have file with many "%" characters in the file
we want to add before every "%" the backslash
as
\%
example
before
%TY %Tb %Td %TH:%TM %P
after
\%TY \%Tb \%Td \%TH:\%TM \%P
how to do it with sed ?
we have file with many "%" characters in the file
we want to add before every "%" the backslash
as
\%
example
before
%TY %Tb %Td %TH:%TM %P
after
\%TY \%Tb \%Td \%TH:\%TM \%P
how to do it with sed ?
Pretty straightforward
$ echo '%TY %Tb %Td %TH:%TM %P' | sed 's/%/\\%/g'
\%TY \%Tb \%Td \%TH:\%TM \%P
but you can accomplish the same with bash parameter substitution
$ str='%TY %Tb %Td %TH:%TM %P'; backslashed=${str//%/\\%}; echo "$backslashed"
\%TY \%Tb \%Td \%TH:\%TM \%P