Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Possible Duplicate:
What does “--” (double-dash) mean?

Can anybody explain me below things

i have file named "-xyz". if i try to remove or move that file using command line , it's unable to move. i tried below things :

[rahul@srv100 ~]# ls -lrt  -- "-xyz"
-rw-r--r-- 1 rahul rahul 0 Dec 19 08:06 -xyz
[rahul@srv100 ~]# mv "-xyz" xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv \-xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -\xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv '-xyz' xyz
mv: invalid option -- x
Try `mv --help' for more information.

finally i rename that file using winscp, and after trying multiple ways i got one option and it's working.

mv -- '-xyz' xyz

Wish the help of "--", i created file/directory as below

mkdir -- --abc
touch -- -xyz

So my Question is what is this "--" in bash ? Please explain.

share|improve this question

marked as duplicate by Stéphane Chazelas, manatwork, Renan, Ulrich Dangel, uther Dec 21 '12 at 12:46

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.

For info, -- has nothing to do with bash. In your case, you can also use ./-xyz. – gniourf_gniourf Dec 21 '12 at 9:56

3 Answers 3

up vote 1 down vote accepted

As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?

As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.

If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc

share|improve this answer

This is used to tell the command that after that point no more command options are accepted.


rm -- -abc

means that it will ignore the - from the abc.

for more information you can refer to:

share|improve this answer
Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments. – gniourf_gniourf Dec 21 '12 at 9:58

It's an indicator to the individual commands to stop interpreting further command line arguments as options.

share|improve this answer

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