I got an error message "a:command not found" while executing a script

yekaso

Honorable
Aug 13, 2013
4
0
10,510
I wrote a script that will iterate through a list of files, tar them, zip and delete the file.
While trying to tar it, this error occured.
"./loop_files.sh: line 32: a: command not found
"

Kindly assist
 

yekaso

Honorable
Aug 13, 2013
4
0
10,510


#!/bin/bash
CURRENTDATE=2013-06


FILES=/opt/xx/xxxx/xxxx/xxxx/

for (( c=1; c<31; c++))
do
ZEROC=`printf "%02d" $c`
NEWCURRENTDATE=${CURRENTDATE}-${ZEROC}


echo "Processing for date ================> $NEWCURRENTDATE";
cd $FILES

for f in `ls -1t $FILES | grep $NEWCURRENTDATE | grep _Nightly_Log_Arc`

do

FILELIST="${FILELIST} ${FILES}$f";

done
if [ "$FILELIST" != "" ]
then

TARFILESCOMMAND="tar cvf ${FILES}${NEWCURRENTDATE}.tar$FILELIST"
GZIPTARFILES="gzip ${FILES}${NEWCURRENTDATE}.tar"
DELETEFOLDERS="rm -rf$FILELIST"

echo "Processing ....tar command ===> $TARFILESCOMMAND"

if `$TARFILESCOMMAND`
then
echo "Processing ....gzip command ====> $GZIPTARFILES"

if `$GZIPTARFILES`
then
echo "Processing ....delete command ===> $DELETEFOLDERS"
`$DELETEFOLDERS`
#gzip the files
fi

#tar the files
fi

#if file list is empty
fi

FILELIST=""
 

yekaso

Honorable
Aug 13, 2013
4
0
10,510


My bad....I didn't copy the done. It was the last line.

From the loop, I added the space already before it. If you execute the script, if there is a match, it prints the shell command before executing it.

tar cvf /opt/xx/xxxx/xx/xx/2013-06-22.tar /opt/xx/xxxx/xx/xx/2013-06-22_0000_Nightly_Log_Arc /opt/xx/xxxx/xx/xx/2013-06-22_1300_Nightly_Log_Arc

If i copy the command it prints out as above and enter in the prompt, this error "a : command not found" does not occur. as shown below.

a /opt/xx/xxxx/xx/xx/2013-06-22_0000_Nightly_Log_Arc/ 0K
a /opt/xx/xxxx/xx/xx/2013-06-22_1300_Nightly_Log_Arc/ 0K


Kindly advice