The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How do you copy files from CD Schnell SCO 2 10-01-2007 04:29 PM
copy of files bkan77 UNIX for Advanced & Expert Users 2 09-06-2007 07:53 AM
copy files from one dir to another mohan705 Shell Programming and Scripting 6 02-21-2007 08:51 AM
How to copy N files from one dir to another GMMike UNIX for Dummies Questions & Answers 1 10-13-2005 09:50 AM
Copy all files 42!? UNIX for Dummies Questions & Answers 4 08-25-2002 01:05 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-27-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
Question how copy only one file with the subfolder?

that's the situation :

copy users/abc/def/car.exe to

own/users/abc/def/car.exe?

the second directory doesn't exists. when you make

cp -p users/abc/def/car.exe own/users/abc/def/car.exe it only

says that the directory "own/users/abc/def" is invalid. I just don't

wanna create all directories by "mkdir".

just copy the file with the root folder to another folder....but not the whole directory, only one file.

thx for all help....

Last edited by svennie; 09-27-2004 at 10:49 AM..
  #2 (permalink)  
Old 09-27-2004
douknownam douknownam is offline
Registered User
  
 

Join Date: May 2004
Posts: 35
try: "cp -pr"

That should copy retaining the permissions, etc. as well as recursively copy the directory structure.
  #3 (permalink)  
Old 09-27-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
I've already tried......the same result.

It can't be that the 'super unix' couldn't copy like the old dos...

for example copy c:/users/abc/cars.exe c:/own/users/cars.exe would work there perfectly.

there must be a way under unix....
  #4 (permalink)  
Old 09-27-2004
douknownam douknownam is offline
Registered User
  
 

Join Date: May 2004
Posts: 35
so you're doing the :

Code:
cp -pr users/abc/def/car.exe own

All you'd need to do in this case would be to create the one "own" folder. But I guess that is the difference between the "super unix" and what you have.. sorry I couldn't help more.
  #5 (permalink)  
Old 09-27-2004
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
Re: how copy only one file with the subfolder?

Quote:
Originally posted by svennie
that's the situation :

copy users/abc/def/car.exe to

own/users/abc/def/car.exe?

the second directory doesn't exists. when you make

cp -p users/abc/def/car.exe own/users/abc/def/car.exe it only

says that the directory "own/users/abc/def" is invalid. I just don't

wanna create all directories by "mkdir".

just copy the file with the root folder to another folder....but not the whole directory, only one file.

thx for all help....


From the Manpage... regarding -r option...

If dest_directory does not exist, cp creates
it and copies the subtree rooted at file1 to dest_directory.
Note that cp -r cannot merge subtrees.


In english that means it will create the directory that is the root for the file being copied....However, IF a file exists that is the same as the source it will fail.


file1. An error occurs if dest_directory/file1
already exists.

Last edited by Kelam_Magnus; 09-27-2004 at 05:30 PM..
  #6 (permalink)  
Old 09-28-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
Question

I just don't understand really.

the source folder and the destination folder aren't the same.

they should be nearly the same so that the subtree of the

copied file is the same but in another folder.

so the destination convert/abc/ dir doesn't exist,

and the file to copy source is abc/test.exe, just taking along the

subfolder.
  #7 (permalink)  
Old 09-28-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
Exclamation whatever ..

when I make

cp -pr users/abc/def/car.exe own

unix only creates a file "own" with the content of "car.exe" under the root folder, that's nonsense.

I've found out that

[cp -p users/abc/test.exe /own] only works if the folder has been prepared, and unix copies the "test.exe" in "/own"

so you'll get sth. like
"own/test.exe"...but I need "own/users/abc/test.exe"...

and if the folder "own" isn't given, you'll get

like messages "no file and no folder"..

so you can't create sth. like

[cp -pr users/abc/test.exe own/users/abc/test.exe] because neither the folder [own] nor the subfolders [own/users] & [own/users/abc] are created.

but I've got to copy some specific files with their subfolder, f.i. [users/abc/test.exe] to the folder [own], that you get finally
[own/users/abc/test.exe]..

but I just don't wanna create all the subfolders, so I wanna make a simple loop, which isn't really a problem. the only problem is the syntax of the cp, look above.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0