Home > OS >  Replace some strings in multiple files?
Replace some strings in multiple files?

Time:12-31

I need to use sed command to replace this string

)/2

to this

) // 2

from all files with .xml in all directories ... I have try this command

find ./ -type f -name '/home/Desktop/Skins/*.xml' -exec sed -i -e 's|)/2|) // 2|g' {} \;

But nothing change and I have got this error !!

CodePudding user response:

Just like that

If you have not subdirectory.

$ cd /home/Desktop/Skins/
$ sed -i -e 's|)/2|) // 2|g' *.xml
$ cat 1.xml
) // 2
$ cat 2.xml
) // 2

$ cat 3.xml
) // 2
)/3
)/4

CodePudding user response:

Using sed

$ echo ')/2' | sed '\~)/2~s~/~ && ~'
) // 2
  •  Tags:  
  • bash
  • Related