Hi I have to move data to a file based on the valuies of first three characters in a file I am using the following script
FIN=$LOC/TEST.TXT
FEEDFILE=$LOC/TUE_GROSSJE.TXT
#Read the file
while read FDROW
do
FEEDROW=$FDROW;
DTYPE=`echo $FEEDROW |cut -c 1-3`
if [$DTYPE=351] ; then
$FEEDROW >> $FIN
fi
done < $FEEDFILE
However whenever I am executing the script I am getting the error as [351=351]: not found
the data with 351 as first three characters is present in the file
Please help
if [ $DTYPE -eq 351 ] ; then
= is for string comparison. Leave a space after and before the square brackets
Just need some spaces and the correct operator ('=' is a tstring comparison operator). Instead of
if [$DTYPE=351]
You should have:
if [ $DTYPE -eq 351 ]
If you wish to compare them as strings you should use quotes (still need the spaces).
if [ "$DTYPE" = "351" ]
Try 'man test' for more information.
Thanks Its seems to have solved the problem but the errror of not found I am now getting is for line
$FEEDROW >> $FIN
Is there any syntax error in the above statement
try echo $FEEDROW >> $FIN