When redirecting the output, using > overwrites an existing file and using >> to append to an existing file.
When I was recording the output of a series of command to a single file, I started to worry about that I could type > instead of >> by mistake and accidentally erase all the hard work I had done.
Here is the save: disable the ability to overwrite a file by setting noclobber:
$set -oshows
noclobber offthen
$set -o noclobberTA-DA, files can not be overwritten anymore. I personally like this setting. If I really want to overwrite a file, I would rm it first, then create a new one.
From Starship Troopers:
http://en.wikiquote.org/wiki/Starship_Troopers_%28film%29
- Ace Levy: Sir, I don't understand. What good's a knife in a nuke fight? All you have to do is press a button, sir.
- Career Sergeant Zim: Put your hand on that wall, trooper. [Ace hesitates] PUT YOUR HAND ON THAT WALL! [Zim throws a knife and hits Ace's hand, pinning it to the wall] The enemy cannot press a button... if you have disabled his hand. Medic!
No comments:
Post a Comment