TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

confused with bash script



I just wrote a bash script to make an .dat file out of a text file for use
in fortune. It will delete the .dat in ~/quotes files for any files it is
remaking and ignore any .dat files, so it won't make .dat.dat files. 

When I run makequotes misc misc.dat it works fine, deletes misc.dat and
makes a new misc.dat and doesn't make misc.dat.dat; however I get the
error:

/usr/local/bin/makequotes: [: =: unary operator expected 

twice.

When I run makequotes * in my quotes directory, I get the same error
message but I also get .dat.dat files. It doesn't make sense. It works
fine for one set of files, but not multiple. 

Here's the script:

#/bin/sh
for QUERY in $*
do
    datafile=`echo $QUERY |grep dat`
    echo $datafile
    echo $QUERY
    if [ $datafile = $QUERY ] ; then
            rm ~/quotes/$QUERY
    else
            echo test
    fi
done
echo part2
for QUERY2 in $*
do
     if [ $datafile = $QUERY2 ] ; then
            echo do nothing
     else
             echo do something
             /usr/sbin/strfile ~/quotes/$QUERY2
     fi
done               




Thanks,

Ben

Ben Luey
lueyb@carleton.edu
ICQ: 19144397