Sign in to follow this  
mrmrcoleman

BASH selective copy question.

Recommended Posts

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 this post


Link to post
Share on other sites
Quote:
Original post by mrmrcoleman
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.
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this