Results 1 to 3 of 3
hi,
I've a machine running RHEL3,kernel version 2.4.
i need to rename multiple files under one directory as follows:
[root@venus ] ls
demo.c demo.S demo-1243.sw demo.xyz
and now i need ...
- 07-14-2008 #1
[SOLVED] Renaming multiple files
hi,
I've a machine running RHEL3,kernel version 2.4.
i need to rename multiple files under one directory as follows:
[root@venus ] ls
demo.c demo.S demo-1243.sw demo.xyz
and now i need to replace the occurrence of demo with demo_1 for each of the above file. the tedious way is to go ahead and do mv on each files, but if i've
huge number of such files and scattered around multiple directories then, a small
script would be of great help.
i think rename might help, but also note that the rename program on 2.4 and 2.6 is different.
~amit
- 07-14-2008 #2
If you have zsh:
Otherwise:Code:autoload -U zmv zmv '(**/)(*demo*)' '$1${2//demo/demo_1}'
Code:find -type f -name '*demo*'| while IFS= read -r; do p="${REPLY%/*}" f="${REPLY##*/}" mv "$REPLY" "$p/${f//demo/demo_1}" done
- 07-14-2008 #3
thank you so much radoulov,
found a solution for this in another forum as well:
for i in $(ls demo*); do mv $i demo_1${i#demo};done


