7

I have files which has name as following:

P50_FR_8_q2_scrolls.csv

Here the value 50 and 8 needs renaming & The results should be something like:

P21_FR_3_q2_scrolls.csv

I tired few similar to rename 's/\d{3}(\d{*})\.csv$P21_$1.csv' *.csv But no luck. (It seems I am really bad at Linux regex)

The value 50->21 and 8->3 is something that i know. But the starting value and ending value is not always in same digit size.

9

Try

rename -n 's/50(_.*)_8/21$1_3/' *.csv

The -n flag doesn't do any renaming. You can test patterns this way. Remove it for actually performing the renaming.

| improve this answer | |
  • 2
    Also provide info that : -n used for no-act and finally remove -n for apply. – Pandya Sep 14 '14 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.