Shanavas M
Shanavas M

Reputation: 1629

How to escape '-' character in console/command line

I have a file named -. How to pass the file name as an argument to console commands ?.

I mean is there a way to escape - character in console ?

Upvotes: 1

Views: 293

Answers (2)

Klas Lindbäck
Klas Lindbäck

Reputation: 33273

You can prepend a path to it, for example:

cat ./-

David A Wheeler has written an in-depth essay on the subject of how to handle file names in shell scripts.

Upvotes: 2

J. Chomel
J. Chomel

Reputation: 8395

For some commands, I know you can say it is the end of the parameters on the command line with a double -.

e.g.:

touch -
rm -- -
rm: Remove -? y

Upvotes: 0

Related Questions