在Linux上删除多个文件的一部分文件名 [英] Removing part of a filename for multiple files on Linux
本文介绍了在Linux上删除多个文件的一部分文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从当前目录中的所有文件名中删除 test.extra
I want to remove test.extra from all of my file names in current directory
for filename in *.fasta;do
echo $filename | sed \e 's/test.extra//g'
done
,但是它抱怨找不到文件.echo是为了确保它正确列出.
but it complains about not founding file.echo is to be sure it list correctly.
推荐答案
首先使用'sed -e'代替'\ e'
First of all use 'sed -e' instead of '\e'
我建议您在bash中这样做
And I would suggest you do it this way in bash
for filename in *.fasta; do
[ -f "$filename" ] || continue
mv "$filename" "${filename//test.extra/}"
done
这篇关于在Linux上删除多个文件的一部分文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文