Steve Youngs wrote:
> 
> Okay, I'm trying to get a script to do one of the following:
> 
>         if [ sizeof(file1) < sizeof(file2)]; then
>                 cp file2 file3
>         fi
> 
<snip>

Interesting task. I came up with the following solution, which is not
optimal, because I have a little variable-scoping-problem here:

#!/bin/bash

size1=$(ls -l file1|(read perms num_hd_links user group size rest; \
echo $size) )
size2=$(ls -l file2|(read perms num_hd_links user group size rest; \
echo $size) )

if [ $size1 -gt $size2 ];then
        # sizeof(file1) > sizeof(file2)
else
        # sizeof(file1) <= sizeof(file2)
fi



Marc

-- 
Marc Mutz <[EMAIL PROTECTED]>                    http://marc.mutz.com/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics

PGP-keyID's:   0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)

Reply via email to