Bash create alias starting with a dash

To create an alias that starts with a dash, use a double-dash to signify the end of the command options.

$ alias -foo="echo bar"
-bash: alias: -f: invalid option
alias: usage: alias [-p] [name[=value] ... ]
$ alias -- -foo="echo bar"
$ -foo
bar
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment