Skip to content

Instantly share code, notes, and snippets.

@lkraav
Created April 27, 2011 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkraav/943802 to your computer and use it in GitHub Desktop.
Save lkraav/943802 to your computer and use it in GitHub Desktop.
#!/bin/sh
TMPFILE=`mktemp`
#save the timestamp
touch -r file-name $TMPFILE
> file_name
#restore the timestamp after truncation
touch -r $TMPFILE file-name
rm $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment