Share your knowledge at the LQ Wiki.
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 12-12-2006, 04:18 AM   #1
Registered: Oct 2006
Posts: 34

Rep: Reputation: 16
Copy directory execlude directory

I'd like to copy all contents of directory except directory name Library, what's syntax should I use.
for example:-
ls /home/user/
redhat centos fedora library and so on
I'd like to copy /home/user/* except library directory
Old 12-12-2006, 04:55 AM   #2
Registered: Sep 2003
Location: Stevenson, WA, USA
Distribution: Slackware
Posts: 232

Rep: Reputation: 30
cp -r /home/user/* /cpdir/ && rm -r /cpdir/library

The "copy files from directory to directory without subfile" thread in the Similar Threads just below also has a solution, but this method seems much less tedious. (Unless of course the "library" directory is so huge it would take hours to copy the whole thing)
Old 12-12-2006, 08:48 AM   #3
Registered: Oct 2006
Posts: 34

Original Poster
Rep: Reputation: 16
Originally Posted by Berto
cp -r /home/user/* /cpdir/ && rm -r /cpdir/library

all files which i need to copy about 10MB but Library directory is 30GB.
I need to use wildcard.
Old 12-12-2006, 08:52 AM   #4
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I like to use rsync with exclude='somedirectory'
For example:
rsync -av --exclude='.thunderbird' /home/fred/ /etc/skel


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
copy file to another directory johnrage Linux - Newbie 1 02-25-2006 02:30 AM
How to copy one directory to another directory thru PHP? green_njk Programming 1 01-06-2006 07:55 AM
best way to copy usr directory petersk Linux - Newbie 4 12-12-2005 07:47 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 12:51 PM
Copy directory structure? tpe Programming 2 06-02-2005 05:59 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:58 AM.

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