An AWK question

antenneX antennex at swbell.net
Fri Feb 4 13:47:37 PST 2005


----- Original Message ----- 
From: "Steven Friedrich" <FreeBSD at insightbb.com>
To: <freebsd-questions at freebsd.org>; "antenneX" <antennex at swbell.net>
Sent: Friday, February 04, 2005 2:23 PM
Subject: Re: An AWK question


> 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 at freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > To unsubscribe, send any mail to
> > "freebsd-questions-unsubscribe at 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...
> -- 

No wonder I couldn't make sense out of it looking only in man GAWK(1).

Now, it's very simple -- thanks a lot!

Jack



More information about the freebsd-questions mailing list