“–” (Double-hyphen) in Bash
$cat out
if [ $# -eq 0 ]
then
echo "Usage: out [-v] filenames..." 1>&2
exit 1
fi
if [ "$1" = "-v" ]
then
shift
less -- "$@"
else
cat -- "$@"
fi
In out the
--arguments to cat and less tells these utilities that no more options follow on the command line and not to consider leading hyphen (-) in the following list as indicating options. Thus--allows you to view a file with a name that starts with a hyphen…--argument works with all Linux utilities that use the getopts builtin… This argument is particularly useful when used in conjunction with rm to remove a file whose name starts with a hyphen (rm -- -fname)…
A Practical Guide to Linux Commands, Editors and Shell Programming (p. 442)