Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How can I rename a lot of files using a regex?
Rename All Files with a Certain Name

There are files with

ORDER_EVENTS_SOMETHING_20120117.log
ORDER_EVENTS_SOME2_20120117.log
ORDER_EVENTS_CHARS_20120117.log

and so on..

I need to rename them to

ORDER_EVENTS_SOMETHING_20120113.log
ORDER_EVENTS_SOME2_20120113.log

and so on..

How can I do that?

share|improve this question
add comment

marked as duplicate by Kevin, Gilles, Michael Mrozek Jan 22 '12 at 19:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

up vote 2 down vote accepted
rename 's/20120117/20120113/' ORDER_EVENTS_*20120117.log

This assumes that all the files to be renamed are in the same directory.

share|improve this answer
add comment

do:

rename -n 's/(.*)_20120117/$1_20120113/' ORDER_EVENTS*

once you sure this is it, remove the -n option.

share|improve this answer
    
Nikhil did easier regexp (+1). Anyhow I will leave this for the reference. –  Michał Šrajer Jan 17 '12 at 15:55
    
+1 for hint on -n switch –  feeela Sep 18 '12 at 21:22
add comment

Or use mmv:

  mmv "*17.log" "#1\13.log"
share|improve this answer
add comment