Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use command ":>file.log" to truncate file.log to zero length. I got it from the internet, but I do not understand how it works. I think that it copies some stream to a file, but I can't manage to find in manual which stream it uses.

share|improve this question

migrated from stackoverflow.com Jun 24 '10 at 9:46

This question came from our site for professional and enthusiast programmers.

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.
share|improve this answer

You may even forget the : part and just type >file.log

It should produce the same result.

share|improve this answer

You must log in to answer this question.