home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3635 < prev    next >
Encoding:
Text File  |  1992-08-26  |  986 b   |  33 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!news.uit.no!ugle.unit.no!news
  3. From: Harald.Eikrem@delab.sintef.no
  4. Subject: Re: How to empty a file
  5. In-Reply-To: ltaylor@blinky.East.Sun.COM's message of 26 Aug 1992 14:31:39 GMT
  6. Message-ID: <1992Aug26.172228*Harald.Eikrem@delab.sintef.no>
  7. Sender: news@ugle.unit.no (NetNews Administrator)
  8. Organization: SINTEF DELAB, Trondheim, Norway.
  9. References: <17g4kbINN4bm@seven-up.East.Sun.COM>
  10. Date: 26 Aug 92 17:22:28
  11. Lines: 20
  12.  
  13. ! >> I'd like to empty a log file after extracting what I need from it so that
  14. ! >> the next day's data can fill it up a-fresh.  The file must exist after
  15. ! >> emptying it.
  16. ! cp /dev/null <logfile>
  17. ! /laura
  18.  
  19. This is definitely a FAQ.  My favourite file making/nulling command is:
  20.  
  21.   : > file
  22.  
  23. which should work from any kind of shell (in csh "noclobber" must be
  24. neutralised).  This construct does not depend on
  25.  
  26.      1) another program (cp, cat, ...)
  27.      2) /dev/null
  28.  
  29.  
  30.   ~~harald E.
  31.