You are currently browsing the LlamaLabs weblog archives for the day Tuesday, April 17th, 2007.

Erase the contents of a file.

I had been using cat /dev/null > /path/to/file for a long time. Whlie reading through a friend’s shell script for creating Amazon EC2 images I found out another way of erasing the contents of a file. > /path/to/file That results in the open system call being called with the O_TRUNC flag. open(“/path/to/file”, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666)

  • April 2007
    M T W T F S S
    « Mar   May »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • Author

    A little something about you, the author. Nothing lengthy, just an overview.