how to copy files ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to copy files ?
# 1  
Old 09-27-2004
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  
Old 09-27-2004
try: "cp -pr"

That should copy retaining the permissions, etc. as well as recursively copy the directory structure.
# 3  
Old 09-27-2004
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  
Old 09-27-2004
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  
Old 09-27-2004
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  
Old 09-28-2004
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  
Old 09-28-2004
Error 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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy files from one drive to another, keeping most recently modified files

Hi all, I am a bit of a beginner with shell scripting.. What I want to do is merge two drives, for example moving all data from X to Y. If a file in X doesn't exist in Y, it will be moved there. If a file in X also exists in Y, the most recently modified file will be moved to (or kept) in... (5 Replies)
Discussion started by: apocolapse
5 Replies

2. Red Hat

Unable to copy files due to many files in directory

I have directory that has some billion file inside , i tried copy some files for specific date but it's always did not respond for long time and did not give any result.. i tried everything with find command and also with xargs.. even this command find . -mtime -2 -print | xargs ls -d did not... (2 Replies)
Discussion started by: before4
2 Replies

3. Shell Programming and Scripting

how to copy files followed by list of names of all the files in /etc?

....... (2 Replies)
Discussion started by: pcbuilder
2 Replies

4. Solaris

How to safely copy full filesystems with large files (10Gb files)

Hello everyone. Need some help copying a filesystem. The situation is this: I have an oracle DB mounted on /u01 and need to copy it to /u02. /u01 is 500 Gb and /u02 is 300 Gb. The size used on /u01 is 187 Gb. This is running on solaris 9 and both filesystems are UFS. I have tried to do it using:... (14 Replies)
Discussion started by: dragonov7
14 Replies

5. UNIX for Dummies Questions & Answers

copy files

Hi Team, I am unable to copy the files, when i run the below script, i am getting error as file not present, not sure what i am missing. # File to be looked upon File_Pattern='*.zip' TMP_FILE=flagfile Check=`find $Directorypath -name $File_Pattern -type f -newer $TMP_FILE -print |... (6 Replies)
Discussion started by: Naveen_5960
6 Replies

6. UNIX and Linux Applications

Copy all files

how i can copy all files " select all " in one step t try command cp -t (2 Replies)
Discussion started by: walidfinder
2 Replies

7. UNIX for Dummies Questions & Answers

copy only new files or files of a different size

hello i would like to copy files from 1 location to a nother, but it has only to copy files which are newer or have a different filesize. all has to be logged to a copy.log file (als skipped files should be in the log) is this possible with the cp command (1 Reply)
Discussion started by: arnoldg
1 Replies

8. SCO

How do you copy files from CD

How do you copy files fra a cd-rom to a directory on the computer? (2 Replies)
Discussion started by: Schnell
2 Replies

9. UNIX for Advanced & Expert Users

copy of files

hi all i have a script,which when executed must copy 3 files from a directory on boxA to the same directory on boxB.I'm using scp to copy these files,the problem is out ofthe 3 files only1 is been copied and not the other 2, i have permissons for the files,any ideas are appreciated thnks (2 Replies)
Discussion started by: bkan77
2 Replies

10. UNIX for Advanced & Expert Users

copy files

Hi, Under the home directory, I want to search for all the *.xml files and move them all into another folder under home. Is it possbile using a single find command . Regards, Chirayu Sutaria (6 Replies)
Discussion started by: chirayus
6 Replies
Login or Register to Ask a Question