<分区>
我有大量文件需要重命名。该名称当前为“sink-foobar”。我想删除'sink-'。一定有办法用 bash 做到这一点,但我运气不好。
<分区>
我有大量文件需要重命名。该名称当前为“sink-foobar”。我想删除'sink-'。一定有办法用 bash 做到这一点,但我运气不好。
最佳答案
简单:
rename 's/sink-//' *files
它是 Perl 版本,有时被命名为 prename
,它在 Ubuntu 和许多发行版上作为默认安装。
为确保您的选择正确,请运行此命令:
file $(readlink -f $(type -p rename)) | grep &>/dev/null -i perl &&
echo "Good version" ||
echo "ELF version, not the good one"
在 Debian 和衍生版(Ubuntu...)上,您可以将其设置为默认值:
update-alternatives --set rename /usr/bin/vendor_perl/rename
关于linux - 使用 linux 删除文件名中的第一个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13661562/