Take the 2-minute tour ×

I saw some postinst script

    # setting wget options
    :> wgetrc
    echo "noclobber = off" >> wgetrc
    echo "dir_prefix = ." >> wgetrc
    echo "dirstruct = off" >> wgetrc
    echo "verbose = on" >> wgetrc
    echo "progress = dot:default" >> wgetrc
    echo "tries = 2" >> wgetrc

What does the :> do here ?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

Nulls out the file called "wgetrc" in the current directory. As in creates an empty file "wgetrc" if one doesn't exist or overwrites one with nothing if it does.

Equivalent to the following:

cat /dev/null > wgetrc
share|improve this answer
Just to clear any possible ambiguity, "nulls out" and "overwriting with nothing" does not mean that "null" characters (hex 00) are written to the space the file was using.. It only tells the filesystem to "mark" that file as having no data in it... Also. you do not need the : at all... >file is enough. –  Peter.O Apr 28 '12 at 5:30
@Peter.O: There are a few cases where >file will not have the same affect as :>file. In particular some interactive shells (zsh by default, bash with options) will interpret that as a time to ask the user for input rather than using null. If you want your code to be portable between interactive and script environments (so it works the same copy/pasted as in a script for example) using :>file is safer. Otherwise, your point about 'nulls out' is well given. –  Caleb Apr 28 '12 at 14:55

Your Answer


