Ignore diriectories within a script

Hi there,
I have a small issue with a script that I am running. I need it to ignore certain dir when copying over files. Ie the code is pointing towards the dir etest but I need to ignore the dirs INLINE and ENG which is contained within this...could anyone give me a pointer on how to do this? I already ignore one dir but how can this be done with multiples....

cheers

colin

cd /etest/
for dir in *; do
   if [ "$dir" = "s25e3" ]; then   
      continue
   fi
   cp -p $dir/${dir}.prb $dir/${dir}.prb.backup
   cp /path/to/s253e.prb $dir/${dir}.prb
done
case "$dir" in
s25e3 | INLINE | ENG )
    ;;
* )
    cp -p $dir/${dir}.prb $dir/${dir}.prb.backup
   cp /path/to/s253e.prb $dir/${dir}.prb
   ;;
esac

Thank for that...I owe u one

Hey there,

I am still having an issue with the script. I get the following error messages:

cp: cannot access /.prb: No such file or directory
cp: cannot create /.prb: Permission denied

Is there something that I have done wrong with the following script?

All the dirs are there...

 
if [ $ANSWER -eq "1" ]; 
then
   echo
   echo
   echo copying recipe probe files now
   cd /users/clyons/eol/
      case "$dir" in
         Inline_ETEST | SA-M1 | SA-M2  | SA-M3  | ENG | GENERIC-S25EA 
      ;;
* )
          cp -p $dir/${dir}.prb $dir/${dir}.prb.backup
          cp /users/clyons/eol/GENERIC-S25EA/GENERIC-S25EA.prb$dir${dir}.prb
   ;;
esac
echo
echo copy complete
fi

Trace the script with "#!/bin/sh -x" as the first line it helps. It looks like the variable "dir" is empty.

I traced the scripty and also looked at the dir which i wanted to copy the backups to and they all contain the files that I need to copy. I know that i am going to the eol dir as the pwd command shows me...I am at a loss. I have checked the code to see if i have a full stop out of place but I cant see anything :frowning:

Any other hints porter?

What about the missing round bracket I indicated?

After the "cd" line, how about a

echo dir=\"$dir\"

to assist tracing?

I had put in the round bracket and made the change to the script as you suggested. The info that i get from the echo command is dir = "//" so it looks like the variable dir is empty. I tried this with the original script and the dir are changed. Is it something with the code that I am not doing right?

Not in the code you posted. Keep moving the echo statement upwards in the script till you find the problem.

hey there,

I kept looking at the script and I have found the problem with it:

I never put in the looping construct to scan through all the sub-directories in the main directory...doh!!

Porter thanks for all your guidence...i appreciate it

#!/bin/sh -x
 
  clear
  echo
  echo
  echo copying recipe probe files now
  cd /users/clyons/eol
  echo ="/$dir/"
    for dir in *;do
              case "$dir" in
                 Inline_ETEST | SA-M1 | SA-M2  | SA-M3  | ENG | GENERIC-S25EA )
               ;;
               * )
                    cd /users/clyons/eol
                    #       pwd
                    echo ="/$dir/"
                    cp -p $dir/${dir}.prb $dir/${dir}.prb.backup
                    cp -p /users/clyons/eol/GENERIC-S25EA/GENERIC-S25EA.prb $dir/${dir}.prb
               ;;
               esac
    done
  echo
  echo copy complete