在linux系统,如果出现一个文件名字以dash “-”开头,例如 -bashname,你怎样对起进行编辑活删除等处理呢?
使用双dash如实现,如:
删除这个文件,你可以使用命令: rm -- -basename
如果你想打开编辑这个文件,你可以使用命令: vim -- -basename
Filenames beginning with "-" may cause problems when coupled with the "-" redirection operator. A script. should check for this and add an appropriate prefix to such filenames, for example, ./-Filename. $PWD/-Filename, or $PATHNAME/-Filename
If the value of a variable begins with a "-", this may likewise create problems.
var="-n"
echo $var# Has the effect of "echo -n", and outputs nothing.