Find and Replace from specific folders

Hello Experts,

Any help is appreciated.

I would like to find and replace a string in a specific file ( e.g abc.xml) only for the directories starting with "AB 1.0 DIR".

I've 50 sub directories starting with "AB 1.0 DIR". And I would like find the file abc.xml in those sub-directories and change the string in that file from test to publish.

Thanks in advance.

Any attempts / ideas / thoughts from your side? Did you consider the find command?

Hi Rudic,

This is what I used and it worked to find the files.

find . -name abc.xml | grep -i "AB 1.0 DIR"

Then I tried to used sed using -exec option to find and replace . But didn't work as expected.

Can you show us how the command was written to try to sed the files, otherwise we will just be guessing a5t what you tried and what went wrong.

Kind regards,
Robin

Have you tried piping the find into awk? There is always an awk for that. :slight_smile: