Copy dir/file from one place to another.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copy dir/file from one place to another.
# 1  
Old 03-03-2010
Copy dir/file from one place to another.

Hello all.
I'm not getting the hang of Paths. I have a dir w/files that I want to copy to another dir. Right now I am in the "source" directory. I want to copy it to Ch7.

"cp -r source Ch7". Ch7 was already created.
1st msg.: cannot stat `source`: No such file or dir.
I typed pwd & got "/home/Ccccc/Ch6/source

then I typed /home/Ccccc/Ch6/source/ Ch7
2nd msg.: no such dir.

Any ideas?
Thanks In Advance
# 2  
Old 03-03-2010
You should probably use -R instead of -r. See this.

Quote:
If the -r option was specified, the behavior is implementation-defined.
In any case you are trying to copy a directory called souece in the current directory (source). If the current directory is source, then that is referenced with . (dot).

i.e.
Code:
$ cp -R . Ch7

Otherwise:
Code:
$ pwd
/home/Ccccc/Ch6/source

$ cd ..
$ pwd
/home/Ccccc/Ch6
$ cp -R source Ch7

(giving the path to Ch7, based on where you currently are)
# 3  
Old 03-03-2010
Spaces in command are important

For instance
Code:
/home/Ccccc/Ch6/source/ Ch7

will access
/ main root directory, then the / to
home directory, then the / to
Ccccc directory, then the / to
Ch6 directory, then the / to
source directory, then the / to
Ch7 file
NOTE that extra space. Unusual, but not ungeard of, for a space to be embedded as the first character in a file.
# 4  
Old 03-04-2010
Quote:
then I typed /home/Ccccc/Ch6/source/ Ch7
2nd msg.: no such dir.
The message you report did not come from the command you say you typed.


What did you actually type?
What was the response?


What is the output from this command (to display your directory tree):

Code:
find /home/Ccccc/ -type d -exec ls -lad {} \;

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Switching between directories and mkdir/copy dir/file

I was trying to copy the files inside the path /home/user/check/Q1/dir/folder1/expected/n/a1.out1 and a1.out2 and a1.out3 to /home/user/check/Q2/dir/folder1/expected/n/ if n directory is not present at Q2/dir/folder1/expected/ then directory should be created first. And, script follow the... (5 Replies)
Discussion started by: Mannu2525
5 Replies

2. UNIX for Dummies Questions & Answers

Issues in Csv file transfer copy from one dir to another

Hi Unix community, I got this code from you guys and I tried to modify it to use for my csv dir transfer basically i want the .csv file to copy itself and populate it to the archive dir. #!/bin/ksh dir1="/home/pumela/unixtestprod" cd "$dir1" echo "code is running" for srcd in... (13 Replies)
Discussion started by: phumaree
13 Replies

3. Shell Programming and Scripting

Copy a field into n line in another place

I have a file contains 100 section (here i show 2 section of that); i want to replace date from 1st & 2nd field of 1st line of each section (1st line of each section is header and the other lines are body) and merg them into one field, then copy it on 7th field of the lines in each section... (17 Replies)
Discussion started by: oreka18
17 Replies

4. UNIX for Dummies Questions & Answers

using gsed with cp to sort files in directory - every N file copy to new place

Hi all, I'm having a problem with some basic piping issues... I have been able to get in a directory and ls | gsed in order to list every N file for instance: ls | gsed -n '2~5p' The thing is I want to be able to copy the output files to a new directory. Basically directory /all has a... (4 Replies)
Discussion started by: dgoss
4 Replies

5. Shell Programming and Scripting

Copy files and subdirs from dir to a new dir

Hello Comunity I am trying to make a bash shell script that it copies files and subdirs(with files) to a new dir. I would like the dest_dir to contain only subdirectories with files not other subdirs inside. it called : cpflatdir src_dir dest_dir Pleaze help me! Thank you in... (2 Replies)
Discussion started by: BTKBaaMMM
2 Replies

6. Shell Programming and Scripting

Copy files from input file with dir structure

hi, I want to copy files from source directory based on input file (or output of previous command) and i want to have the SAME DIRECTORY STRUCTURE. Note that i will have other files and directories which i dont want to copy to destination. For example, dir source has following content:... (22 Replies)
Discussion started by: dragon.1431
22 Replies

7. Shell Programming and Scripting

Copy Files to Dir and Check If File Exists

Hi everyone. I am trying to write a bash script that will copy files from one directory to another but I need to be able to check the directory that I'm copying the files to and see if the file already exists. If it does I need to add a number at the end of the copied file. Thanks for your help. (3 Replies)
Discussion started by: snag49ers
3 Replies

8. Solaris

What is the best way to copy data from place to another place?

Dear Gurus, I need you to advice or suggestion about the best solution to copy data around 200-300G from serverA(location A) to serverB(location B). Normally, I will share folder and then copy but it takes too long time(about 2 days). Do you have any suggestion or which way should be... (9 Replies)
Discussion started by: unitipon
9 Replies

9. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

10. Shell Programming and Scripting

how to copy a file to a directory ,where file and dir are sent as args to a function?

Hi all, I wanted to know how i can copy a file to a directory and then verify if that file is completely copied or not? Now the issues here is that the dir and the source file are to be sent as arguments to a function( this function should actually copy the files to a dir, then check if its... (0 Replies)
Discussion started by: wrapster
0 Replies
Login or Register to Ask a Question