PDA

View Full Version : Rename all files to something else in Linux


SneakyDave
08-26-2002, 12:21 PM
Is there a single copy (cp) statement that will go through all subdirectories and copy all occurrences of a file called "today" to "yesterday"?

I really need to rename the files from today to yesterday, but move (mv) doesn't seem to utilize a recursive option.

Bruce
08-26-2002, 12:24 PM
Try this: find * -name today | while read today; do cp $today `dirname $today`/yesterday; done or, if you are using bash as your shell: find * -name today | while read today; do cp $today ${today%/today}/yesterday; done

SneakyDave
08-26-2002, 01:42 PM
bash: ${$today%/today}/yesterday: bad substitution

That's the response I get

SneakyDave
08-26-2002, 01:46 PM
Whoops, must've had a typo. It works great now. Thanks!