Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

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".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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