5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Linux — ハイフンで始まるファイルを削除する

Last updated at Posted at 2018-07-26

解決

ダブルダッシュの後に消したいファイル名を書く。

rm -- -file.txt

意味

ダブルダッシュ ( -- ) はコマンドフラグの終わりを表すらしい。

The double dash “–” means “end of command line flags

UNIX - BASH - What does “--” (double-dash) mean? (also known as “bare double dash”)-Learn in 30 Sec from Microsoft Awarded MVP

問題

-file.txt がコマンドオプションと認識されてしまい、消せなかった。

$ rm -file.txt
rm: illegal option -- l
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file

エスケープも不可。

$ rm '\-file.txt'
rm: \-file.txt: No such file or directory

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

5
2
2

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
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?