14

How can I create a file named "-file" using command line in Linux?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
sebthesaviour
  • 153
  • 1
  • 1
  • 6

3 Answers3

19

specify a path in front of it, e.g. ./-file

Stefan Hegny
  • 2,107
  • 4
  • 23
  • 26
17

In bash -- is a flag that is interpreted as "nothing after this should be taken as a flag", so - is no longer parsed as an option.

touch -- -file
karel
  • 5,489
  • 46
  • 45
  • 50
0
ls -ltr | awk '$NF ~ /^--/{print "rm ./" $NF}'|sh
user8854776
  • 173
  • 1
  • 7
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: https://stackoverflow.com/help/how-to-answer . Good luck – nima Oct 19 '21 at 12:38
  • thanx a lot! :) – sebthesaviour Oct 19 '21 at 15:23