sago sago - 2 years ago 159
Linux Question

How colon and semicolon differs in linux command?

How the colon and semicolon differs in the following linux commands?

who am i:

who am i;

Answer Source

In this case it really doesn't matter much.

Usually, a ; is used to mark the end of a command in certain situations:

if [[ ... ]]; then ...; else ...; fi

The who command, however, will produce the same output regardless of what the two words on the command line is. The : is not special:

$ who am i

$ who makes dinner

$ who ano.L::e se=el

These will produce the exact same output.

So, to answer the question:

  1. The : is part of the word i: and doesn't mean anything special here.
  2. The semicolon marks the end of the command, and is not needed since there is no other command on the line after it.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download