LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-10-2003, 03:59 PM   #1
hamster
Member
 
Registered: Apr 2003
Location: Waterford, Ireland
Distribution: Mandrivia 2006.1, Ubuntu 7.10
Posts: 188

Rep: Reputation: 30
cp command problem..... unexpected result


I have this structure:

tempdir3
tempdir2
|--tempfile1
|--tempfile2
|--tempfile3
|
|--tempdir1
......|--tempfile1
.....|--tempfile2
.....|--tempfile3

I want to copy /tempdir2/tempdir1/tempfile1 into tempdir3...

ie I want the stucture /tempdir2/tempdir1/tempfile1 in /tempdir3 not just the file tempfile1...

I used the command:
cp -p /tempdir2/tempdir1/tempfile1 tempdir3
This only copies tempfile1 into tempdir3. I want the structure from /tempdir2 onwards to go in there. Grrr!

It's like as if I'm just doing:
cp /tempdir2/tempdir1/temp1file1 tempdir3...

I'm using Redhat 8 and the man page isn't really clear on this. Any ideas?

Last edited by hamster; 04-10-2003 at 04:00 PM.
 
Old 04-10-2003, 04:44 PM   #2
glock27linux
LQ Newbie
 
Registered: Nov 2002
Posts: 29

Rep: Reputation: 15
If I read you correctly, you'd like to see the following as a end result:

./tempdir3/tempdir2/tempdir1/tempfile1

One of the quickest ways I can see doing that is:

tar -cpf newcopy.tar tempdir2/tempdir1/tempfile1
tar -C tempdir3 -xpf newcopy.tar

that'll create ./tempdir3/tempdir2/tempdir1/tempfile1 for you, and only that. Using cp recursively would grab other files as well as tempfile1.
This help?
 
Old 04-10-2003, 04:57 PM   #3
hamster
Member
 
Registered: Apr 2003
Location: Waterford, Ireland
Distribution: Mandrivia 2006.1, Ubuntu 7.10
Posts: 188

Original Poster
Rep: Reputation: 30
glock27linux,

Yep, thats what I'm trying to do. The exerise (Sam's 24 hour book actually) was trying to show that you could pluck just one of the 3 files outta there without moving the whole lot... because that would have been easy, ie:

cp -r tempdir2/tempdir1 tempdir3

I see you tar the structure and file and extract it inside tempdir3 instead. Another way. I see you use the -p parameter there too and that's what I had hoped would work with my cp line.

Thanks.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output the result of a command to a file darkarcon2015 Linux - Newbie 1 09-24-2005 06:29 PM
Unexpected behaviour with the find command dazdaz Linux - General 3 12-15-2004 08:50 PM
BASH Command Result redhatnoob Programming 2 08-19-2004 06:25 PM
MySQL queries from Shell - unexpected result philipz Programming 5 05-04-2004 05:38 PM
Unexpected Behavior (passwd command) Penguin666 Linux - General 3 11-19-2003 11:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:26 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