linux : empty file from command line
Being faced with large log files that contains info you no longer need ?
cat
reads the contents of /dev/null (which contains nothing) and > writes this into <filename>.
$ cat /dev/null > <filename>
see more : http://hackaddict.blogspot.be/2007/06/quick-tip-delete-contents-of-file.html
Written by Wim Paulussen
Related protips
2 Responses
$ echo > <filename>
and even shorter, but I don't like the aesthetic
$ > <filename>
over 1 year ago
·
"echo > foo" doesn't create an empty file, it creates a file of size 1
"> foo" does work correctly.
A traditional alternative is the bash builtin ":" which does nothing:
:> foo
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Related Tags
#linux
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#