Explain ":>"
In bash, help : you get:
:: : No effect; the command does nothing. A zero exit code is returned. It is worth noting that, as mentioned earlier : usually replaces the truth, as in
while : do date sleep 60 done But, strictly speaking,: it is not needed in your team, and you can just write
> /server/logs/access_log To avoid trimming important files unintentionally, it is best to set the noclobber parameter
set -o noclobber and if you try to do it, he will spit
-bash: /server/logs/access_log: cannot overwrite existing file if you want to force him
>| /server/logs/access_log Being : a do-nothing statement in bash (equivalent to true , as WebMonster points out), this command actually creates and truncates the size 0 of the next file.
Note that you can usually use touch to create an empty file that does not exist, but if the file exists and contains data, you should empty it. This is a way to do both things at once.