LinuxQuestions.org
Visit Jeremy's Blog.
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, 02: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, 02:21 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608Reputation: 3608
You need something that you can easily --exclude things with. Two tools come to mind: 'tar' and 'rsync'.
 
Old 01-19-2010, 04:53 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430

Rep: Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787Reputation: 2787
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 09:57 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
script or utility to copy files and folders m2azer Linux - General 1 12-22-2005 10:09 AM
copy files and folders codepoet Linux - Newbie 2 06-12-2005 02:08 PM
how to copy files/folders??? Gallienus Linux - General 4 12-15-2003 12:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:30 PM.

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
Open Source Consulting | Domain Registration