Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Unix tools: what if a file is named minus something?

Please tell me how to escape this:

[root@unix ~]# ./-sh
-bash: ./-sh: Permission denied
[root@unix ~]# chmod +x -sh
chmod: invalid mode: `-sh'
Try `chmod --help' for more information.
[root@unix ~]#
share|improve this question

marked as duplicate by Daniel Beck Jan 4 '13 at 16:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

# chmod a+x "\\-sh" chmod: cannot access `\\-sh': No such file or directory – soundhax Jan 4 '13 at 16:23
up vote 2 down vote accepted

Use --.

E.g. chmod +x -- -sh. In GNU language the -- means end of options, so -sh is no longer parsed as an option.

[Edit] Added example:

beetle:/home/hennes/test>touch -- -sh

beetle:/home/hennes/test>ls -l -- -sh
-rw------- 1 hennes users 0 2013-01-04 17:20 -sh

beetle:/home/hennes/test>chmod +x -- -sh

beetle:/home/hennes/test>ls -l -- -sh
-rwx------ 1 hennes users 0 2013-01-04 17:20 -sh
share|improve this answer
Interestingly, this doesn't seem to work with GNU echo, although it works with GNU printf. This works: printf -- -sh. And this does not: echo -n -- -sh. – Lukas Pokorny Jun 18 '15 at 12:50

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