[plug] bash script program help

Lance Duivenbode lduivenb-mlist at iinet.net.au
Wed Jan 11 09:16:22 WST 2006


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



Russell Steicke wrote:

>On Wed, Jan 11, 2006 at 09:01:34AM +0800, Cameron Patrick wrote:
>
>  
>
>>>  function filesize() {
>>>    echo $(ls -l $1 | awk '{print $5}')
>>>  }
>>>      
>>>
>>This can be done more directly using stat(1), e.g.
>>
>>    filesize () {
>>        stat -c %s $1
>>    }
>>    
>>
>
>Ah, very nice.  Thanks.
>
>And the "echo $()" was superfluous, too.  :(
>
>  
>
>>This seems to be slightly Linux-specific, though: it's there on *BSD but
>>it isn't present on Solaris or Tru64.
>>    
>>
>
>Not on AIX 5.2, either.
>
>
>
>  
>




More information about the plug mailing list