- The double dash “–” means “end of command line flags” i.e. it tells the preceding command not to try to parse what comes after command line options.
- It is actually part of the POSIX standard that — can be used to separate options from other arguments, so you will see it on commands like cp and mv (which are not part of Bash).
- — works to separate options from regular expressions in grep, but the canonical way is to use -e/–regexp
you want to grep a file for the string -v – normally -v will be considered the option to reverse the matching meaning (only show lines that do not match), but with — you can grep for string -v like this:
A double dash ( — ) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted
Suppose you have a file named path/to/file.txt in my Git repository, and you want to revert changes on it.
Now suppose that the file is named master…
Whoops! That changed branches instead. The — separates the tree you want to check out from the files you want to check out.
It also helps us if some freako added a file named -f to our repository: