如何使用bash/sed脚本删除mp3文件的第一个和第二个下划线?

如何使用bash/sed脚本删除mp3文件的第一个和第二个下划线?,bash,sed,scripting,Bash,Sed,Scripting,我有mp3,比如这是我的mp3.mp3 我想要这个这是我的Mp3.Mp3 感谢您的帮助简单明了: % sed -e 's/_/ /g' -e 's/ / - /2' <<<'This_is_my_Mp3.mp3' This is - my Mp3.mp3 使用mv,此版本实际上会重命名当前目录中的文件(请小心使用!): 用于*.mp3中的文件;做 mv“$file”“$”(sed-e's/\uu//g'-e's/-/2)您的标题与问题的主体不匹配。您真正想做什么? for f

我有mp3,比如这是我的mp3.mp3 我想要这个这是我的Mp3.Mp3

感谢您的帮助

简单明了:

% sed -e 's/_/ /g' -e 's/ / - /2' <<<'This_is_my_Mp3.mp3'
This is - my Mp3.mp3
使用mv,此版本实际上会重命名当前目录中的文件(请小心使用!):

用于*.mp3中的文件;做

mv“$file”“$”(sed-e's/\uu//g'-e's/-/2)您的标题与问题的主体不匹配。您真正想做什么?
for file in *.mp3; do
sed -e 's/_/ /g' -e 's/ / - /2' <<<"$file"
done
for file in *.mp3; do 
mv "$file" "$(sed -e 's/_/ /g' -e 's/ / - /2' <<<$file)"
done