sago sago - 7 months ago 36
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;


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.