I accidentally created a file with the name -
(eg, seq 10 > -
). Then I tried to use less
to view it, but it just hangs.
I understand that this is happening because less -
expects input from stdin
, so it does not interpret the -
as a file name. I tried less \-
but it does not work either.
So, is there any way to indicate less
that -
is a file and not stdin?
The best I could get is:
find -name '-' -exec less {} +
Best Answer
Just prefix it with
./
:Or use redirection:
Note that since
-
(as opposed to-x
or--foo--
for instance) is considered a special filename rather than an option, the following doesn't work: