Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

add comment

2 Answers

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
add comment

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

It should produce the same result.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.