Home  >  Article  >  System Tutorial  >  How to use commands to batch modify file names under CentOS?

How to use commands to batch modify file names under CentOS?

WBOY
WBOYforward
2024-01-05 08:09:051116browse

I encountered a new problem today. What if I want to cut off the suffixes in batches?

The specific commands are as follows:

find -name "*.txt" |for i in *;do mv $i `echo $i |sed 's/\.txt//g'`;done

find -name "*.txt" |awk -F'.' '{print $1} |xargs mv {}.txt {}

If you only want to modify the suffix name, use rename. The command is as follows:

rename .txt .bk *

The above is the detailed content of How to use commands to batch modify file names under CentOS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete