bash mv: 无效选项 -- '0'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6557985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 00:17:11  来源:igfitidea点击:

mv: invalid option -- '0'

bashcommand-line-interfacemvbatch-rename

提问by Roger

How can I rename files with "-" in front of the filename, for example: "-0001.jpg"

如何重命名文件名前面带有“-”的文件,例如:“-0001.jpg”

Everyime I try to run:

每次我尝试运行:

for i in *; do mv "$i" "${i//-/}"; done

or:

或者:

for i in *; do mv "$i" "${i#*-}"; done

I got this error:

我收到此错误:

mv: invalid option -- '0'
Try `mv --help' for more information.

Thanks for any light!

谢谢你的光!

回答by jm666

mv ./-00008.jpg to/some/where.jpg
   ^ - start with path...

回答by jcomeau_ictx

as with most gnu commands, use the --switch before the filename with the hyphen. it signifies "end of switches".

与大多数 gnu 命令一样,--在文件名前使用带连字符的开关。它表示“开关结束”。

回答by ShinTakezou

Put a double - before the arguments that can contain "-" in the begin; then there can't be options after --.

在开始的可以包含“-”的参数之前放一个双 - ;那么在 -- 之后就没有选项了。

mv OPTIONS -- ...