Date: Tue, 09 Apr 2002 12:32:27 -0500 From: Sean O'Neill <sean@seanoneill.info> To: Zhihui Zhang <zzhang@cs.binghamton.edu>, freebsd-questions@freebsd.org Subject: Re: monitor the growth of a file. Message-ID: <5.1.0.14.0.20020409123041.00ad6de0@postoffice.swbell.net> In-Reply-To: <Pine.SOL.4.21.0204091307360.2802-100000@onyx>
next in thread | previous in thread | raw e-mail | index | archive | help
At 01:09 PM 4/9/2002 -0400, Zhihui Zhang wrote: >I have a text file that grows steadily by an application. Is there a way I >can monitor the growth of it? One way is to write a script with a line >like "cat filename | tail" in a loop. But is there a better way? Not if you want to hurt yourself - LOL. If you want to see content as it is added simply do a "tail -f <filename>". If you want to monitor its "growth" you need something like (I use ksh93 - modify it for your own shell): #!/usr/local/bin/ksh PREV=$(ls -l <filename> | awk '{print $5}') while [ 1 ]; do sleep 30 CURR=$(ls -l <filename> | awk '{print $5}') echo $((CURR - PREV)) PREV=$CURR done -- ........................................................ ......... ..- -. .. -..- .-. ..- .-.. . ... ............ .-- .. -. -... .-.. --- .-- ... -.. .-. --- --- .-.. ... Sean O'Neill To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.1.0.14.0.20020409123041.00ad6de0>