From owner-freebsd-questions Tue Apr 9 10:32:37 2002 Delivered-To: freebsd-questions@freebsd.org Received: from chivas.oneill.dhs.org (chivas.oneill.dhs.org [65.65.85.161]) by hub.freebsd.org (Postfix) with ESMTP id 2DCE937B400 for ; Tue, 9 Apr 2002 10:32:34 -0700 (PDT) Received: from v812r.seanoneill.info (dhcp1.NONROUTABLE [192.168.2.1]) by chivas.oneill.dhs.org (Postfix) with ESMTP id 2D805767D; Tue, 9 Apr 2002 12:32:28 -0500 (CDT) Message-Id: <5.1.0.14.0.20020409123041.00ad6de0@postoffice.swbell.net> X-Sender: swoneill@postoffice.swbell.net X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 09 Apr 2002 12:32:27 -0500 To: Zhihui Zhang , freebsd-questions@freebsd.org From: Sean O'Neill Subject: Re: monitor the growth of a file. In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 ". 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 | awk '{print $5}') while [ 1 ]; do sleep 30 CURR=$(ls -l | 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