cp command in linux
he,
I have some trouble when i try to make a shell script that copies windows files from a samba share. #cp -r /app/ftp/NO_lo\ 01.07.2007 /app/ftp_new/ cp: cannot stat `/app/ftp/NO_lo\ 01.07.2007 ': No such file or directory Hope somebody can help me with this one. |
The error you see simply means that your shell can't find the files/directory you indicate.
Try doing: Code:
ls -ld '/app/ftp/NO_lo\ 01.07.2007' |
Quote:
|
Quote:
Or try using the absolute path, like in my example. Quote:
Did you also notice the different spelling? In the cp -r command, the directory name starts with "NO_lo", whereas in the ls commands you used "NE_lo". |
>Did you also notice the different spelling? In the cp -r command, the directory name starts with
>"NO_lo", whereas in the ls commands you used "NE_lo".[/QUOTE] Sorry, i change the file name. My problem is that there is space in the file i want to copy, it is an windows file in a samba share. Is it possible to do an for loop or something to copy the windows file with space in linux? [ftp]$ ls -ltr *NE* -rwxr-xr-x 1 root root 210304 Jun 30 2006 NE_lo 01.07.2006 |
This was addressed in another thread I recently contributed to:
http://www.linuxquestions.org/questi...d.php?t=530568 So, please take a look at the posts of that thread. If you still have questions after that, then post back on this thread. Edit: during the copy, you might want to change the filenames so that they don't include the space any more. Code:
#Let's assume that the original name is stored in the variable $fileName (this can be your If you don't want the replacing to spaces, you can added other characters as well, or use tr's character classes. |
Quote:
hi, I still have some problem with this copy script. When i try to copy the windows file with spaces, it still dont work: [root@$ ls -ltr *NE* -rwxr-xr-x 1 root root 32704 Dec 1 20:22 NE 02.12.2006 [root@$ find /app/disk1/~name/ -iname "*NE*" | \ while read I; do cp "$I" /app/disk2/~name2/in.txt; done; -bash: syntax error near unexpected token `do' As you can see, i am trying to copy the content of("*NE*") into this file /app/disk2/~name2/in.txt |
I recommend that you simplify your command.
For instance, use find's -exec option to execute your cp command on each item found. Don't forget to terminate the -exec option with \; As for the error, I think your command is a little screwed up. After the \ line separator, I expected to see a newline. The shell may not see the 'while' command and hence has a problem interpreting the 'do'. But that's just my first impression. |
Quote:
Can you please help me with this command? |
What part of my post isn't clear to you? Or with which part of the command do you need help?
|
Quote:
Hi, When i am trying to take the data from *NE* file and put it into source_inn.txt in the commeand under here. #find /data/out/ftp/~files/ -iname "*NE*" | while read I; do cp "$I" /data/in/source_inn.txt; done; Nothing happens when i use this command, can you please help me to get this command or something else so i can get the data from *NE* over in the text file source_inn.txt.. Thanks again. |
All times are GMT -5. The time now is 06:27 AM. |