The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Reg: Search for a directory Rajanikanth Linux 1 01-08-2008 04:06 AM
Reg: Search for a directory Rajanikanth UNIX for Dummies Questions & Answers 1 01-07-2008 03:36 AM
Reg: Search for a directory Rajanikanth Shell Programming and Scripting 0 01-07-2008 03:30 AM
Reg: Search for a directory Rajanikanth UNIX for Advanced & Expert Users 0 01-07-2008 03:28 AM
Directory tree search??? solvman High Level Programming 3 09-28-2001 10:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-07-2008
Registered User
 

Join Date: Jan 2008
Posts: 11
Reg: Search for a directory

Dear All,

I am new to Unix and i need a small Help from you Guys.....

The current structure of my system is as follows:
/Abc/xyz/cpd/std/re/doc

Each cpd directory has n number of std's. Each std has n number of re's.
My requirement is to write a UNIX script that would search whether doc directory is present under all re's directories.
If it is not, i need to write it into a temp file with the full path /Abc/xyz/cpd/std/re/doc.

Can anyone of you help me in writing a UNIX script for the above mentioned requirement ASAP.

Looking forward to your response.

Thank You.

Regards,
Rajani-kanth.
Reply With Quote
Forum Sponsor
  #2  
Old 01-07-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Post

Code:
for dir in /Abc/xyz/cpd/*/* ; do if [ ! -d $dir/doc ]; then echo $dir >> /tmp/tempfile.txt ; fi ; done
(untested)
Reply With Quote
  #3  
Old 01-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 11
i have done changes to the script according to my requirement but sorry to say that it's not working...........
Reply With Quote
  #4  
Old 01-08-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Quote:
Originally Posted by Rajanikanth View Post
i have done changes to the script according to my requirement but sorry to say that it's not working...........
It works for me, try posting the error message...
What shell are you using? The above code is for any bourne-style shell - ie it won't working under csh or tcsh
Reply With Quote
  #5  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 11
Hi ...
Thanks for your help.....and we are using : /bsh

i have saved the file with name : test1.sh
after compiling with : ./test1.sh it si showing nothing...so i have checked for the file under :/abc/xyz//tem/tempfile.txt but i was not able to find it.

Regards,
Rajanikanth.
Reply With Quote
  #6  
Old 01-09-2008
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 734
Quote:
Originally Posted by Rajanikanth View Post
we are using : /bsh

i have saved the file with name : test1.sh
after compiling with : ./test1.sh it si showing nothing...so i have checked for the file under :/abc/xyz//tem/tempfile.txt but i was not able to find it.
I've never heard of bsh, the code snippet above can be run directly from the commandline of any bourne-style shell (sh, ksh, bash for examples). You can also put it into a shell script if you need to of course but make sure you use a bourne-style interpreter (eg #!/bin/sh at the start of the script)

Are you seeing any errors output at all?

If you've modified it, perhaps posting the new version might help us find what's wrong.

As a quick method of debugging, I'd also suggest removing the '>> /tmp/tempfile.txt' part so you can see what it's doing more easily.
Reply With Quote
  #7  
Old 01-09-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
# find /Abc/xyz/cpd*/std*/re* ! -name "doc" > temp
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0