LoginSignup
48
19

More than 5 years have passed since last update.

ハイフンで始まるファイルの削除方法

Posted at

はじめに

コマンドラインでいろいろ弄っていたら、ハイフンで始まるファイルができてしまった。
-c というファイルを消そうとしても、そんなオプションはないと怒られ、消せない。

$ rm -c
rm: invalid option -- 'c'
Try `rm --help' for more information.

man コマンド を見る

To remove a file whose name starts with a `-', for example `-foo', use one of these commands:
rm -- -foo
rm ./-foo

どうやら、2通りあるようだ。
冷静に考えたら、./ をつけたら良いって思いつくな・・・

ハイフンで始まるファイルの削除

$ rm -- -c

終わりに

最初びっくりしたけど、消せて良かった。
めでたしめでたし

48
19
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
48
19