Find a pattern in files and rename them in Unix

How to Find a pattern in files and rename them in unix?

Many a times we come across the requirement to rename the files in folder by removing some pattern from it.

If it’s one or two files its fine but if it is more than 10 files than we try to find a solution to automate it or a quick command to do it.

Below command will make your day 😉

 find . -name “*” -exec bash -c ‘mv $0 ${0/_2016*.DAT/.DAT}’ {} \;

 

rename_file_patter

Vikram Pawar

Vikram Pawar

Coder by passion..... Thirsty for knowledge, challenges & most importantly innovation. Working with BNP Paribas

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *