plhn plhn - 1 year ago 105
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download