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.

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
add comment

1 Answer

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
add comment

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