Empty logfiles

2012-08-29 Thread Jos Chrispijn

Stupic question: I have a directory with 120 logfiles (extension *.log).
Can someone tell me how I can empty these logfiles in one command?
I thought 'echo  *.log' would work, but no way K-)

thanks
Jos Chrispijn
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Empty logfiles

2012-08-29 Thread Robert Bonomi
 From owner-freebsd-questi...@freebsd.org  Wed Aug 29 15:02:37 2012
 Date: Wed, 29 Aug 2012 21:59:17 +0200
 From: Jos Chrispijn po...@webrz.net
 To: freebsd-questions@freebsd.org
 Cc: 
 Subject: Empty logfiles

 Stupic question: I have a directory with 120 logfiles (extension *.log).
 Can someone tell me how I can empty these logfiles in one command?
 I thought 'echo  *.log' would work, but no way K-)

Assuming 'sh', or something 'syntactically equivalent':

for file in *.log ; do ; echo  $file ; done



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Empty logfiles

2012-08-29 Thread Steve O'Hara-Smith
On Wed, 29 Aug 2012 21:59:17 +0200
Jos Chrispijn po...@webrz.net wrote:

 Stupic question: I have a directory with 120 logfiles (extension *.log).
 Can someone tell me how I can empty these logfiles in one command?
 I thought 'echo  *.log' would work, but no way K-)

find . -name \*.log -exec truncate {} \;

man find and man truncate for the gory details.

-- 
Steve O'Hara-Smith at...@sohara.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org