[plug] bash script program help

Richard Meyer meyerri at westnet.com.au
Wed Jan 11 12:44:42 WST 2006


On Wed, 2006-01-11 at 09:16 +0800, Lance Duivenbode wrote:
> Another way is to use cut(1):
> 
> #!/bin/sh
> 
> fileA=$1
> fileB=$2
> 
> sizeA=`du $fileA | cut -f 1`
> sizeB=`du $fileB | cut -f 1`
> 
> echo $sizeA
> echo $sizeB
> 
> if [ "$sizeA" -gt "$sizeB" ]; then
>   echo 'Greater'
> else
>   echo 'Less'
> fi
> 

And my $0.02
richard1 at Selous:~> ll Arcanum_Walkthru.html
-rw-rw-r--  1 richard1 users 276984 2004-08-01 23:15
Arcanum_Walkthru.html

richard1 at Selous:~> wc -m Arcanum_Walkthru.html | cut -f1
276984 Arcanum_Walkthru.html

richard1 at Selous:~> wc -m Arcanum_Walkthru.html | cut -f1 -d' '
276984

I needed the "-d" to tell cut that my delimiter was not a tab character.
And wc was the first thing the came to mind - I'm sure others are
faster/better/less overhead. But it shows there's always more than one
way to do anything.

And as for the looping characteristics - I'd set something up like some
of the other responders have suggested.

-- 
Richard Meyer <meyerri at westnet.com.au>




More information about the plug mailing list