0

what I a trying to do is to use find to edit/replace string in multiple files with same name in multiple directories with consistent form

multiple files:

status1_cap

multiple directories:

/home/user/directory/subdirectory1
/home/user/directory/subdirectory2
/home/user/directory/subdirectory3
...

I looked at these resources:

Find and replace text within multiple files

https://alvinalexander.com/blog/post/linux-unix/find-how-search-multiple-folders-directories-unix/

But the solutions are not exactly the same.

I was thinking something like this would work?:

find /home/user/directory/subdirectory{*} -name \status1_cap.txt -exec sed -i "s/cap=1/cap=2/g" {} \;

Is there a way a one line cmd that could do this?

2
  • Do you really need find here? if you know where all the files are, a simple shell glob like /home/user/directory/*/status1_cap should suffice Mar 20, 2021 at 23:46
  • @steeldriver hm I dont really feel comfortable that it would be going thru all files...thats why...
    – charlie090
    Mar 21, 2021 at 0:07

0

You must log in to answer this question.

Browse other questions tagged .