Linux 命令参数 -

对于Linux命令参数中被误解析成-xxx的参数问题,如

1
2
[root@HBSpy extreme]# rename -mib
rename: invalid option -- 'm'

可以在参数前加–

1
[root@HBSpy extreme]# rename -- -mib .mib extreme-*

参考: https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean

More precisely, a double dash (–) is used in most bash built-in commands and many other commands to signify the end of command options, after which only positional arguments are accepted.
Example use: lets say you want to grep a file for the string -v - normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with – you can grep for string -v like this:
grep – -v file