, possibly others), a quick easy way to null
something. Say you want to erase a file (without deleting it, maybe the file is often written to but if it's not there, something breaks). Say this file is /etc/passwd
. You would do the following:
and said file would now have absolutely nothing in it. Much faster to type than
cat /dev/null >/etc/passwd
This works because in bash, the colon is the equivalent of a null command, and is a builtin The exit status of : is true.