How to replace a string in multiple files in multiple folders with different hierarchy in linux command line
I have many files with the extension *.launch distributed in different folders inside the parent directory, the hierarchy is not always the same for the .launch file.
i.e: src/folder/sth.launch and src/folder2/../../another.launch, so this solution doesn't work here!
How can I replace a string xarco.py with another string xarcoin all these*launch files in different folders and levels using Linux command?
thanks in advance.
1 Answer
When in the parent directory, you can try with the following command,
find . -type f -name "*.launch" -exec echo sed -i 's/ {} \;and if it 'looks good' remove echo to do the real job,
find . -type f -name "*.launch" -exec sed -i 's/ {} \;If there are problems with permissions, you may need to prefix with sudo:
sudo find ... 1