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

command -- 

What does this -- mean?

9

2 Answers

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 --foo 

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.

2

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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