LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2010, 03:07 PM   #1
eikhorsholm
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Copy all files except from some certain folders.


At the moment I'm using:
"cp -ap . /destination-folder"
to copy everything from the folder I'm in to another folder.
That works.

Is it possible to cp everything except:
folder1/
folder2/
in the current folder I'm in?
 
Old 01-19-2010, 03:21 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
You need something that you can easily --exclude things with. Two tools come to mind: 'tar' and 'rsync'.
 
Old 01-19-2010, 05:53 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
As implied by unSpawn, there is (unfortunately) no --exclude option for cp.
Other solutions include:

1. cp everything, then rm at the destination
2. write a short script to call cp, skipping those dirs
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy files from diffrent folders to a single folder cadcrazy Linux - Software 3 09-18-2008 10:57 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 03:27 PM
script or utility to copy files and folders m2azer Linux - General 1 12-22-2005 11:09 AM
copy files and folders codepoet Linux - Newbie 2 06-12-2005 03:08 PM
how to copy files/folders??? Gallienus Linux - General 4 12-15-2003 01:02 PM


All times are GMT -5. The time now is 03:01 AM.

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