我如何输入带前缀'-t'的目录

问题描述 投票:0回答:1

错误,我在Linux服务器上创建了带有前缀'-t'的目录。例如,-train-20200514-081411。当我想cd -train-20200514-081411时,出现错误:

-bash: cd: -t: invalid option
cd: usage: cd [-L|-P] [dir] 

因此,在这种情况下,如何使用此目录?

非常感谢您的帮助!

linux directory
1个回答
1
投票

您可以使用:

cd -- -train-20200514-081411

--告诉bash不要将任何其他项目解释为标志,下面的示例脚本:

[~]: mkdir -- -turkey; ls
-turkey  other_file.txt

[~]: cd -- -turkey

[~/-turkey]: cd ..

[~]: rmdir -- -turkey; ls
other_file.txt
© www.soinside.com 2019 - 2024. All rights reserved.