bash - 我想删除322个文件名的前8个字符

标签 bash shell ubuntu

我有 322 个文件,所有文件都以 "533682 - " 开头(这是我想从他们中删除的)我使用这个脚本但没有工作:

for file in 533682*
do 

    mv $file $(echo $file | sed -e 's/^........//')

done

最佳答案

使用 Perl 的独立 rename命令:

rename 's/^.{8}//' 533682*

关于bash - 我想删除322个文件名的前8个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50515322/

相关文章:

c - 对 'FCGX' 的 undefined reference

regex - Bash 正则表达式在句子中查找特定单词

bash - 为什么运行 sed 命令会截断我路径的第一个字母?

bash - 在 shell 脚本中使用变量作为命令行输入

python - 使用 subprocess.Popen 运行需要多个输入重定向的 unix 工具

python - 某些 python 库在生产中的 Django 应用程序中未加载,但在本地服务器中加载正常

linux - 从搜索结果中忽略文件夹及其文件

bash - 在 bash 中将条件放入猫体内

bash - Shell 脚本中的 bool 表达式

linux - Ubuntu 14.04 中某些根目录的所有权意外更改