plhn plhn - 2 months ago 6x
Bash Question

cat `-q` file (in linux)

I have a file whose name is

(It looks like this is made by accident)

I want to see it’s content, so I tried these

$ cat '-q'
$ cat "-q"
$ cat $'-q'

But nothing worked.(All gives same error
cat: invalid option -- 'q'

Is there any way to see it’s content?


to create a file named -q do

touch -- "-q"

and to view its contents

cat -- "-q"

should do it. -- means what follows should be treated as a positional parameter.