# BASH selective copy question.

## Recommended Posts

mrmrcoleman    320
Hello, I am trying to copy one directory tree to another, but I don't want to copy any file which has .svn in it's path. If anybody has a solution, could you also possibly point me towards some good material on this subject? I'd rather know how to do this in future instead of sapping the collective talents of the GD boards every time I have a BASH question! Kind regards, Mark

##### Share on other sites
Bregma    9202
Quote:
 Original post by mrmrcolemanI am trying to copy one directory tree to another, but I don't want to copy any file which has .svn in it's path.
find srcdir $$! -name . -a ! -path \*.svn\*$$ -exec cp {} dstdir \;
where srcdir and dstdir are your source directory and destination directory, respectively. Alternatively,
find srcdir ! -name . | grep -v \.svn | xargs -i== cp == dstdir
is likely to be faster for larger directories.
Quote:
 If anybody has a solution, could you also possibly point me towards some good material on this subject?
man find will give you the manual for the find command. Between find, grep, sed, and the occasional xargs you can do pretty much any file manipulation you can dream up. They all have man pages.

##### Share on other sites
mrmrcoleman    320
That did it.

Thanks.

##### Share on other sites
WilyCoder    100
why not just use the svn export command to get a copy of that directory without the .svn folders?