Terminal (bash?) / Docker: logic behind – and —
For three days I am learning to work with Docker.
During this I ran commands like
nc -lp 1234
I was wondering why I have to use sometimes a
- and for other commands a
Is there any logic?
Regarding the topic of my question: I am aware that it is not a good topic. I am sorry for that. This question occurred while working with Docker but I do not know if the
-- thematic is more a terminal or docker topic.
2 Solutions collect form web for “Terminal (bash?) / Docker: logic behind – and —”
It depends on the command. There are conventions, but none of them are followed universally.
In the Old Days, options were single letters. If an option took an argument, it could follow the option letter with or without an intervening space (
command -x foo or
Options that don’t take arguments can be bundled, so
command -x -y can be written as
command -xy. For many commands, even options that do take arguments can be bundled, with the last specified option taking the argument:
command -x -y foo vs.
command -xy foo. The
nc -lp 1234 in your question is an example of this;
p are two different options. That could also have been written as
nc -l -p 1234.
Commands from the GNU project can typically accept options either in the traditional short form and in a long form, where the option name is an entire word that can be abbreviated as long as the abbreviation is unique. For example,
ls has a
-F option to append a
/ to directory names and so forth. Gnu
ls lets this be specified as
--classify, or abbreviated as
--cl. To avoid ambiguity and for backwards compatibility, old-style single-letter options use a single
-, while long-form options use
Finally some commands take options with long names introduced by a single
find command is an example of this.
The only real solution is to read the man page for the specific command you’re running.
A single dash can be followed by multiple single-character flags. A double dash is followed by a single, multi-character flag.
in your case
sudo docker run --rm -ti --net=example --name server ubuntu:14.04 bash
rm (multi-character) t (single) i (single) net (multi-character) name (multi-character)
nc -lp 1234
l (single) p (single)