I have log files like this:
tmp_1_2_3_4_5.LOG
...
I need to change name like this:
1_2_3_4_5.LOG
I try:
rename 's/^tmp+_//' *
It's working on Debian, but not working on Red Hat. How can I do this with mv command?
I have log files like this:
tmp_1_2_3_4_5.LOG
...
I need to change name like this:
1_2_3_4_5.LOG
I try:
rename 's/^tmp+_//' *
It's working on Debian, but not working on Red Hat. How can I do this with mv command?
You can do this with a fairly simple for-loop:
for file in tmp_*; do
[[ -e $file ]] || continue
mv "$file" "./${file#tmp_}"
done
Also see BashFAQ #30
You can try this, with mv :
for i in *; do s=$(sed -r 's/^(tmp_)(.*.LOG)/\2/' <<< $i); if [[ "$i" != "$s" ]]; then mv "$i" "$s"; fi; done;