LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Bash script to strip a certain directory out of directories in a directory? (http://www.linuxquestions.org/questions/linux-general-1/bash-script-to-strip-a-certain-directory-out-of-directories-in-a-directory-477252/)

rylan76 08-25-2006 08:34 AM

Bash script to strip a certain directory out of directories in a directory?
 
Hi

I use CVS to develop PHP code, but when uploading the PHP, I always have to strip the CVS directory out of every directory in a directory by hand... since the CVS directories are not needed online.

How would a bash script look like that would allow me to input the directory to "strip", and which will then recursively for an arbitrary sub-directory depth and number of subdirectories, strip all the named folders out of those directories?

I. e. I want to strip all the CVS/ folders out of all the directories and their subdirectories of the current directory...

Thanks!

timmeke 08-25-2006 08:41 AM

Try looking at the 'find' command, rather than a script.
ie:
Code:

find /your/top/dir -type d -name 'CVS' -exec rm -rfi {} \;
should pull off what you need.

Instead of rm'ing them, you could also make them unaccessible to the user that your web server runs under. That way, the CVS directory is not accessible via a browser, but it's still there, so your CVS sandbox and web site directory are still in one place.

pbdanl 08-26-2006 05:32 AM

Alternatively, you could use the "cvs export" command to create a fresh checkout without all the CVS administration directories, which you could then use for upload....

rylan76 08-29-2006 11:35 AM

Thanks!! This will surely help me a lot. Appreciate it!


All times are GMT -5. The time now is 01:40 PM.