我有一些文件的名称如下:
2311110-1_1.umi_bc1.fastp.fq.gz
2311110-1_1.umi.fastp.fq.gz
现在我想把名字改成:
231110-1_1.umi_bc1.fastp.fq.gz
231110-1_1.umi.fastp.fq.gz
在谷歌搜索后,我尝试使用命令“重命名”:
rename 's/2311110/231110/' 2311110*
但是,我这样做之后,它不起作用。文件名不会改变。 那么命令有没有错误呢?顺便说一句,文件太多了,不可能用“mv”更改名称。
如果你使用bash,你可以使用变量替换:
for i in 2311110*
do
# just remove the echo when you tested that proposed mv command seems good
echo mv $i ${i/2311110/231110}
done
请参阅 devhints.io/bash 了解有关变量操作的更多信息。
在 Ubuntu Linux 上,安装了
rename
软件包(sudo apt-get install rename
,您的 rename 命令对我有用:
$ touch 2311110-1_1.umi_bc1.fastp.fq.gz 2311110-1_1.umi.fastp.fq.gz
$ ls 23111*.gz
2311110-1_1.umi.fastp.fq.gz 2311110-1_1.umi_bc1.fastp.fq.gz
$ rename 's/2311110/231110/' 2311110*
$ ls 23111*.gz
231110-1_1.umi.fastp.fq.gz 231110-1_1.umi_bc1.fastp.fq.gz