Results 1 to 2 of 2
I have a mass of directories called */small
I need to rename them all to */web
I was thinking of
find . -type d -name 'small' -exec mv {} "${{}//small/Web}" ...
- 10-19-2009 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 19
[SOLVED] String replacement on command line - help!
I have a mass of directories called */small
I need to rename them all to */web
I was thinking of
find . -type d -name 'small' -exec mv {} "${{}//small/Web}" \;
This obviously won't work, but I obviously need to repeat the {} somehow in the second mv argument so I can do the replacement operation on the pathname.
It would also be nice if I could specify that the text 'small' that I want to replace is only replaced where it is at the end of the pathname and not embedded in another directory name higher up the directory tree.
Does that make sense?
Steve
- 10-19-2009 #2Just Joined!
- Join Date
- Dec 2008
- Posts
- 19
Sorry - Found the answer
find . -type d | while read file; do echo mv "$file" "${file/%small/Web}"; done

Now to read up on 'while'


