Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-25-2006, 08:34 AM   #1
Senior Member
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,542

Rep: Reputation: 101Reputation: 101
Bash script to strip a certain directory out of directories in a directory?


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...

Old 08-25-2006, 08:41 AM   #2
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Try looking at the 'find' command, rather than a script.
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.
Old 08-26-2006, 05:32 AM   #3
LQ Newbie
Registered: Aug 2006
Location: netherlands
Distribution: fedora, ubuntu
Posts: 4

Rep: Reputation: 0
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....
Old 08-29-2006, 11:35 AM   #4
Senior Member
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,542

Original Poster
Rep: Reputation: 101Reputation: 101
Thanks!! This will surely help me a lot. Appreciate it!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to access all files in a directory shinni Programming 5 04-24-2009 03:46 PM
Using Bash, Find script files in a directory or subdirectories within... ray5_83 Programming 4 10-10-2008 07:42 PM
script to gzip all directories in a directory br8kwall Programming 11 09-06-2005 10:42 PM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
triggering bash script if directory modified cbb Linux - Software 1 10-23-2004 07:52 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration