How linux command ":>" works?
The command isn't :>
it's just :
. In bash (and probably some other shells) it's a built-in no-op command. The >
redirects output to a file (truncating it first). Since :
has no output, the net result of your command line : > file.log
just makes file.log
zero length.
From my local bash
man page:
: [arguments]
No effect; the command does nothing beyond expanding arguments
and performing any specified redirections. A zero exit code is
returned.
You may even forget the :
part and just type >file.log
It should produce the same result.