From owner-freebsd-questions@FreeBSD.ORG Fri Feb 4 20:24:04 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3383716A4CE for ; Fri, 4 Feb 2005 20:24:04 +0000 (GMT) Received: from sccimhc91.asp.att.net (sccimhc91.asp.att.net [63.240.76.165]) by mx1.FreeBSD.org (Postfix) with ESMTP id C262543D49 for ; Fri, 4 Feb 2005 20:24:03 +0000 (GMT) (envelope-from FreeBSD@insightbb.com) Received: from [192.168.1.239] (12-202-28-183.client.insightbb.com[12.202.28.183]) by sccimhc91.asp.att.net (sccimhc91) with ESMTP id <20050204202359i9100k4qe3e>; Fri, 4 Feb 2005 20:24:03 +0000 From: Steven Friedrich To: freebsd-questions@freebsd.org, antenneX Date: Fri, 4 Feb 2005 15:23:58 -0500 User-Agent: KMail/1.7.2 References: <005c01c50aed$d105c3b0$0200000a@SAGEAME> In-Reply-To: <005c01c50aed$d105c3b0$0200000a@SAGEAME> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200502041523.59163.FreeBSD@insightbb.com> Subject: Re: An AWK question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2005 20:24:04 -0000 On Friday 04 February 2005 02:14 pm, antenneX wrote: > ---> FBSD-4.10p2 > > I have a script that tells me when a mailbox exceeds 2MB. Using it for > another purpose. how can I modify this script to tell me when a file is > LESS than a certain size? > > --------------------------------------------- > #!/bin/sh > > #AWK=/usr/bin/awk > #FILE=/file/size/to/check > #LS=/bin/ls > #SIZE=2048 # (2048 = 2MB) > > #if [ `${LS} -s ${FILE} | ${AWK} '{ print $1 }'` -gt ${SIZE} ]; then > # echo File ${FILE} is ABOVE normal | mail -s "Alert: Check the file" > #fi > --------------------------------------------- > > Thanks, and.... > > Best regards, > > Jack L. Stone > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" Jonathen's correct. It's not an awk question. It's actually being evaluated by test. see man test )test is also invoked when you see [ some equation ] (you need the space at least on the inside of [ and ], perhaps on the outsides too. #if [ `${LS} -s ${FILE} | ${AWK} '{ print $1 }'` -lt ${SIZE} ]; then # echo File ${FILE} is BELOW normal | mail -s "Alert: Check the file" #fi awk is just being used to get the first field from ls -s, which is the size... -- i386 FreeBSD 4.11-STABLE