
$ echo "here is some jibberish" > somefile.txt
$ cat somefile.txt
here is some jibberish
$ cat /dev/null > somefile.txt
$ cat somefile.txt
$
Essentially by calling "cat /dev/null > somefile.txt" we redirect nothing (/dev/null) to the file 'somefile.txt', which in effect empties it. I like to use this for emptying log files as it saves time recreating files and possibly resetting the right permissions.
If interested, you can read more on I/O redirection.
No comments:
Post a Comment