简体   繁体   中英

Bash script to rename all files in a directory

I have a directory with a bunch of files names like this:

DetailedFeatureNameIntegrationTest.java

and I want to rename all the files to

DetailedFeatureNameIntegTest.java. 

I just want to replace 'Integration' with 'Integ' is there a quick way to do this?

Using pure bash ,

for f in *.java; do
    mv -- "$f" "${f//ration/}"
done

assuming you don't have a situation like both DetailedFeatureNameIntegrationTest.java and DetailedFeatureNameIntegTest.java already in the same directory.

使用perl rename实用程序:

rename 's/Integration/Integ/' *.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM