I have seen many tutorials that use a -- after commands. Something like this:

command -- 

What does this -- mean?

  • What video tutorials? Jul 2, 2016 at 16:20
  • See unix.stackexchange.com/q/11376/6949.
    – edwinksl
    Jul 2, 2016 at 16:20
  • Actually, I am surprised that this question was not already a dupe on AU. Do identical questions on other StackExchange communities not count as dupes (viz the link given by @edwinksl) ? What's the take on that ? Maybe I should ask that on META....
    – Cbhihe
    Jul 2, 2016 at 16:29
  • @Cbhihe I am not aware of a mechanism that allows us to point to duplicate targets of other SE sites. Anyway, it doesn't happen too often, so there is probably no need for one.
    – edwinksl
    Jul 2, 2016 at 16:32
  • 3
    @anonymous2 why in the world would we do that? The question is on topic here, so it can stay. Moving it would remove information from AU and add nothing new to U&L, so I don't see why it would be a good thing.
    – terdon
    Jul 2, 2016 at 16:49

2 Answers 2


The -- is used to indicate the end of command line options. This enables you to use arguments starting with --. For example, if you create a file called --foo:

$ > '--foo'
$ ls

And then try to delete it, rm will think you're giving it an argument:

$ rm --foo 
rm: unrecognized option '--foo'
Try 'rm ./--foo' to remove the file '--foo'.
Try 'rm --help' for more information.

One way around this is to use --:

$ rm -- --foo

This is common practice and recommended by POSIX, so it's supported by many programs.

  • 13
    It is not implemented by Bash at all. It is a feature of the rm program and of many POSIX-compliant utilities. See Guideline 10. To actually check that it isn't Bash doing the work (and that wouldn't make sense), just create a small script with just printf '> %s <\n' "$@" and launch it with --. Jul 2, 2016 at 17:02
  • 3
    @gniourf_gniourf d'oh! I did check by writing a little perl script that prints its options and it doesn't see any if you pass it a --, but, of course, that's simply because the relevant Perl module (getopts) also supports it. You're quite right, I just quickly searched man bash, saw the section I had quoted but failed to notice that it was in the "command line options" section. Thanks for the correction, answer edited.
    – terdon
    Jul 2, 2016 at 17:29

Most commands will use a -- to tell the command that further parameters should be treated differently. One example is the rm -- --filename noted above. Another example, a script like 'startx' will interpret itself everything before -- , and pass everything after it to the X server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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