Like ., : works more or less like true. Unlike ., : is a more portable version of true as : is a special POSIX built-in (read: required), whereas true is a regular built-in (read: optional).
Nowadays both : and source (from now on I will use just :) are used in very clever ways:
- Persisting environments (only true for
:but not in zsh):
$ unset x; ( x=hi :; echo "$x" )
hi
$ unset x; ( x=hi true; echo "$x" )
# hi no printed
- Command logging:
% set -x # set -x, makes the shell print out the command before running it
% : Logging message here
% example_command
- Cron job titles
This usage is similar to above, clever!
45 10 * * * : Backup for database ; /opt/backup.sh
- Skipping block of codes:
: << 'SKIP'
your code block here
SKIP
Reference: What is the purpose of the : (colon) GNU Bash builtin?