LoginSignup
1
0

More than 5 years have passed since last update.

コマンドラインで `-` から始まるファイルを扱う時の方法

Posted at

例えば -foo ってファイルがあったら普通にコマンドラインで処理すると
「-foo なんてオプションはねーよ!」という感じのエラーになります。

対策1

./-foo のように書く。

対策2

-- "-foo" のように書く。 -- は「オプションとしての引数の終了」を意味するbash の build-in なのでこれ以降にかけばファイル名だと認識される。

参考

shell - What does "--" (double-dash) mean? - Unix & Linux Stack Exchange
http://unix.stackexchange.com/questions/11376/what-does-double-dash-mean

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0