LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 06-08-2005, 07:31 AM   #1
basher400
Member
 
Registered: Mar 2005
Posts: 54

Rep: Reputation: 15
simple cp command question


lets say I have a folder by the name of "myfolder"
which subfolders: "folder1" "folder2" and "folder3"
and there are other files in "myfolder" as well.

how do I use the "cp" command to copy everything in folder "myfolder" including files and subfolders excluding "folder2"?




thanks
 
Old 06-08-2005, 07:48 AM   #2
akilles
Member
 
Registered: Sep 2004
Location: Vestfold, Norway
Distribution: Slackware
Posts: 139

Rep: Reputation: 15
cp -R /folder /to/folder

(-R means recursive)

-geir

EDIT:
Didn't catch the last thing about not including folder2

easiest is probably to delete the folder2 after it's copied..


Last edited by akilles; 06-08-2005 at 07:51 AM.
 
Old 06-08-2005, 07:50 AM   #3
basher400
Member
 
Registered: Mar 2005
Posts: 54

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by akilles
cp -R /folder /to/folder

(-R means recursive)

-geir
but that will not exclude "folder2", will it ?
 
Old 06-08-2005, 07:52 AM   #4
akilles
Member
 
Registered: Sep 2004
Location: Vestfold, Norway
Distribution: Slackware
Posts: 139

Rep: Reputation: 15
just edited my original post.
(sorry I didn't catch the last line first time.)

-Geir
 
Old 06-08-2005, 08:05 AM   #5
basher400
Member
 
Registered: Mar 2005
Posts: 54

Original Poster
Rep: Reputation: 15
I'm afraid deleting after copying is not I want, I have to avoid copying it in the first place.

let me ask this differently - and this what I really want to do:
how do I copy a certain folder recursively with its sub folders and everything in it and keep the symbolic links in it as symbolic links at the destination ?

what happens now is when I run this:
cp -r -p mysource mydes

symbolic links in "mysource" are turned into folders in "mydes" containning the files those symbolic links point to at "mysource" - I want them to be kept symbolic links only
 
Old 06-08-2005, 08:08 AM   #6
akilles
Member
 
Registered: Sep 2004
Location: Vestfold, Norway
Distribution: Slackware
Posts: 139

Rep: Reputation: 15
try using capital R instead of small.

cp -R -p ....

cp --help to see what they do

-Geir
 
Old 06-08-2005, 08:17 AM   #7
basher400
Member
 
Registered: Mar 2005
Posts: 54

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by akilles
try using capital R instead of small.

cp -R -p ....

cp --help to see what they do

-Geir
capital R gave me the same result
 
Old 06-08-2005, 08:26 AM   #8
akilles
Member
 
Registered: Sep 2004
Location: Vestfold, Norway
Distribution: Slackware
Posts: 139

Rep: Reputation: 15
If the symlinks point to the full path, and not just to the paths in that folder, symlinks will stay the same
ln -s /home/user/test4 test5
cp -R /home/user /test

the symlink /test/user/test5 now points to /home/user/test4

-Geir
 
  


Reply



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
simple and easy ls command question basher400 Linux - Newbie 1 06-15-2005 08:26 AM
A shell command simple question the_rhino Linux - Newbie 6 09-13-2004 01:57 PM
Simple resolve.conf question (Search Command) rrosenkoetter Linux - Networking 2 04-05-2004 07:46 PM
Simple scripting question - running a command for a specified time FluoroAlien Programming 8 03-06-2004 12:33 AM
Simple question about mount command Manuel Tejada Linux - General 3 11-02-2002 10:33 PM

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

All times are GMT -5. The time now is 07:29 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
Open Source Consulting | Domain Registration