Clearing the content of a file

This is mostly a note for myself, but sharing is caring.

To clear the content of a file:

$ echo "" > filename

To fill a file with junk:

$ cat /dev/urandom > filename

This is easier to write and

This is easier to write and does the same job:

$ > filname

Also you can limit how many bites you want in your random junk file like this:

cat /dev/random | head -c NUMBER_OF_BITES > file

Submitted by Flexer (not verified) on Wed, 01/02/2008 - 11:02.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><pre><blockquote>
  • Lines and paragraphs break automatically.
  • Insert Flickr images: [flickr-photo:id=230452326,size=s] or [flickr-photoset:id=72157594262419167,size=m].

More information about formatting options