Ignore diriectories within a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ignore diriectories within a script
# 1  
Old 11-02-2007
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

Code:
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

# 2  
Old 11-02-2007
Code:
case "$dir" in
s25e3 | INLINE | ENG )
    ;;
* )
    cp -p $dir/${dir}.prb $dir/${dir}.prb.backup
   cp /path/to/s253e.prb $dir/${dir}.prb
   ;;
esac

# 3  
Old 11-03-2007
Thank for that...I owe u one
# 4  
Old 11-03-2007
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...
Code:
 
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

# 5  
Old 11-03-2007
Quote:
Originally Posted by lodey
Inline_ETEST | SA-M1 | SA-M2 | SA-M3 | ENG | GENERIC-S25EA )
Trace the script with "#!/bin/sh -x" as the first line it helps. It looks like the variable "dir" is empty.
# 6  
Old 11-03-2007
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 Smilie


Any other hints porter?
# 7  
Old 11-03-2007
Quote:
Originally Posted by lodey
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to ignore mutiple strings when using shell script?

Hi All, I am trying to use below syntax to find ignore multiple locations while searching for a file. find / -name "$serviceitem" ! -size 0 2>&1 |egrep -v "tmp|docker|WinSxS|Permission|HISTORY|alternatives|bearer11ssl|manifest" I tried to assign all the ignore strings to one variable... (2 Replies)
Discussion started by: sravani25
2 Replies

2. Shell Programming and Scripting

Ignore .txt in find script

Hi i am really new to linux scripting and i need a little bit help. i have the following script: find "/usr/share/nextcloud/data/__groupfolders" -type f -mtime +14 -exec rm {} \; but i don't want to delete everything. I want to ignore .txt files. How can i do this? (3 Replies)
Discussion started by: Frederic
3 Replies

3. Shell Programming and Scripting

How to ignore error in command in bash script?

Hello, i have bash script where im cycling some command for different lines in external file. example: while read domain;do nslookupout=$(nslookup -type=ns $domain) || true another commands done < filenamewithdomains i added: || true after the command in belief it will just skip... (6 Replies)
Discussion started by: postcd
6 Replies

4. Shell Programming and Scripting

Ignore Folder in Shell Script ?

Hi, I currently use a script to extract *.deb files located in a Directory called "/var/mobile/Media/Downloads" The Problem is howver I want the script to ignore the folder: "/var/mobile/Media/Downloads/New Debs and Files" (it shall NOT decompile any of the files in that folder. Here is... (2 Replies)
Discussion started by: pasc
2 Replies

5. Shell Programming and Scripting

Ignore lines in Shell Script

Hi, I have a shell script, which reads a *.txt file - line by line. In this text file, I have some lines beginning with "#" that I want to ignore : MY_FILE #blah blah blah 1 blah blah blah 2 blah blah blah 3 #blah blah blah 4 I want my script to read only the following lines... (3 Replies)
Discussion started by: ad23
3 Replies

6. Shell Programming and Scripting

script to ignore the user from list of users

Hi, I have a situation where I want to ignore few users from list of users and print rest of user in log file. say, I want to ignore aaa, bbb, ccc, ddd .. ppp from list of 20 user (do not want to include) What is the good command or any script? Thanks in advance. (1 Reply)
Discussion started by: sumit30
1 Replies

7. UNIX for Dummies Questions & Answers

How to ignore errors in script

I have a simple script that processes files. Here's a simplified example of what I'm doing: foreach t (web.*) mv $t dnw$t:e.log end foreach t (card.*) mv $t card$t:e.log end The problem is that sometimes there is no web.* file. In that case, I get an error "foreach: No match" and... (4 Replies)
Discussion started by: software5723
4 Replies

8. UNIX for Advanced & Expert Users

Script to ignore word from a line ...

Hi Gurus, I'm need of a script in which we are finding an independent word ‘boy' in a log file. We are using grep in order to do the same. Now in this log file there are some sentences where we see ‘This is a boy' and we do not want to count word ‘boy' from this sentence. So in other word we want... (2 Replies)
Discussion started by: heyitsmeok
2 Replies

9. Shell Programming and Scripting

Make python script ignore .htaccess

I just wrote a tiny script with the help of ghostdog74 to search all my files for special content phrases. After a few modifications I now made it work, but one problem is left. The files are located in public_html folder, so there might also be .htaccess files. So I ignored scanning of that... (4 Replies)
Discussion started by: medic
4 Replies

10. Shell Programming and Scripting

ignore negative number in script

Hi, does anyone know how to ignore whether a number is negative in a script. E.g. if I have a variable that contains -1200, how do I ignore the minus sign? (1 Reply)
Discussion started by: borderblaster
1 Replies
Login or Register to Ask a Question