Question

Linux/Bash, I have a directory with many directories inside of it. the inside directories occasionally have the same name of FOO. I want to rename every occurrence of FOO to BAR.

Alternatively, just make git think BAR every time it ever heard FOO. I want the files to stay in their place.

Also, not sure a basic rebase will work to scrub FOO out, due to FOOs being introduced many times.

I have tried:

#!/bin/ksh
for oldfile in $(find . -name FOO*)
do
   newfile="BAR"
   mv "$oldfile" "$newfile"
done

edit: have also tried: find . -name foo -type d -execdir mv {} bar \;

but i get

find: `./w08/foo': No such file or directory

Was it helpful?

Solution

You can use find with -execdir:

find . -name "FOO*" -execdir mv '{}' bar \;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top