The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-27-2009
cbo0485 cbo0485 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 87
Find directory and create backup

What I'm attempting to do is create a script that will do a search for directories that meet the following criteria:


Code:
find . -name "config" -type d

this comes back with:

./dir1/anotherDir/test_dir/config
./dir1/anotherDir/test_dira/config
./dir2/test/test_dir/config

The results could be 10 directories or only 2, but once it comes back with the results I need to change directories to the parent directory of the config directory, then run


Code:
tar czf config.tgz config
/dir/to/another/script.sh config.tgz
mv config.tgz_new_file_name /backup/dir

I got most of it down, just the part where I want to CD to the parent directory of each result.