3

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 1

6

When in the parent directory, you can try with the following command,

find . -type f -name "*.launch" -exec echo sed -i 's/xarco.py/xarco/g' {} \;

and if it 'looks good' remove echo to do the real job,

find . -type f -name "*.launch" -exec sed -i 's/xarco.py/xarco/g' {} \;

If there are problems with permissions, you may need to prefix with sudo:

sudo find ...
1
  • 2
    This, because it allows a "dry-run".
    – Fabian
    Oct 14, 2021 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .