I somehow got a file named --no-recursion in a directory. How can I get cat to show what it contains? Not like this, since the argument gets interpreted as an option:

root@nagini [/home/lalilulelo]# cat --no-recursion 
cat: unrecognized option `--no-recursion'
Try `cat --help' for more information.
root@nagini [/home/lalilulelo]# cat \--no-recursion 
cat: unrecognized option `--no-recursion'
Try `cat --help' for more information.
root@nagini [/home/lalilulelo]# cat \\--no-recursion 
cat: \--no-recursion: No such file or directory
link|improve this question

63% accept rate
feedback

1 Answer

up vote 5 down vote accepted

What happens is that cat treats --no-recursion as its option. You can do either of the following:

cat ./--no-recursion

OR

cat -- --no-recursion

Can do the same thing with rm to delete this file (since it's probably an error of some kind).

In my first example, I prepended current directory path ("./") to the file name, so it does not start with an option prefix, and in my second example I added a special option --, which means "stop treating anything that comes after this as an option".

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.