Unix Shell Script (looping through records)

I am new to Unix shell scripting and just need to create a simple script that compares the checksums of a directory to that of a directory on another computer, however, when assigning variables to the system call I get errors, here is my code:
#!/bin/bash
FILES="*"
for f in "$FILES"
do
  a=cksum $f
  b=rsh myUnixName -l myUserId cd /export/home/config; cksum $f

 if [ $a != $b ]
 then
   echo "Attention - $f does not match"
 fi
done

Open in new window

konradsadekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
#!/bin/bash
FILES="*"
for f in "$FILES"
do
     a=$(cksum $f)
    b=$(rsh myUnixName -l myUserId "cd  export/home/config; cksum $f")

   if [ "$a" != "$b" ]
    then
         echo "Attention - $f does not match"
   fi

done

 - execute commands and assign the result to a variable with $(  )   or  `   `
 - enclose remote commands in double quotes "  " to protect metacharacters  like the semicolon from being interpreted by the local shell
 - compare the right variables
- use double quotes around string variables to protect possibly contained spaces
 - use ssh wherever possible, rsh is considered insecure
 
 wmp
0
woolmilkporcCommented:
. sorry, overlooked one thing

for f in $FILES

- without quotes, else the content of $FILES will be trated as one single string.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
konradsadekAuthor Commented:
Wonderful - thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.