Unable to copy contents


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to copy contents
# 1  
Old 11-20-2015
Unable to copy contents

I am trying to move content of a folder using
Code:
ls /backup/db_backups/INCREMENTAL/|while read file ; do
mv $file /backup_LOCAL/db_backups/INCREMENTAL/
done

...but when I run this command using a bash script I'm getting this error
Code:
 ./test.sh
mv: cannot stat `1.0.db2inst2.DBPART000.20151119062453.001.gz': No such file or directory
mv: cannot stat `2.0.db2inst2.DBPART000.20151119062528.001.gz': No such file or directory
mv: cannot stat `3.0.db2inst2.DBPART000.20151119062540.001.gz': No such file or directory
mv: cannot stat `4.0.db2inst2.DBPART000.20151119061646.001.gz': No such file or directory
mv: cannot stat `5.0.db2inst2.DBPART000.20151119062518.001.gz': No such file or directory
mv: cannot stat `6.0.db2inst2.DBPART000.20151119062504.001.gz': No such file or directory

Code:
ls -l /backup_LOCAL/
drwxrwxr-x   4 db2inst2 db2iadm1       4096 Nov 12 04:52 backup_LOCAL

Is this some thing permission issue ? but I can move files to /backup_LOCAL mv command manually but not using bash .

Last edited by rbatte1; 11-23-2015 at 05:22 PM.. Reason: Changed ICODE tags to CODE tags and corrected spelling
# 2  
Old 11-20-2015
Your lssupplies file names without paths; so mv will search in the cwd and fail unless your cwd is the source directory.
# 3  
Old 11-20-2015
oh ok you mean should i need to be there in pwd before running this command ?
# 4  
Old 11-20-2015
That were one option. Another were using a variable holding the path for both the ls and the mv command.
# 5  
Old 11-20-2015
Finally i modified my script like this .
Code:
# MOVE BACKUPS TO backup_LOCAL/db_backups FROM /backup/db_backups/
cd /backup/db_backups/INCRMENTAL/
#mv /backup/db_backups/INCRMENTAL/*.* /backup_LOCAL/db_backups/INCREMENTAL/
ls /backup/db_backups/INCREMENTAL/|while read file ; do
mv $file /backup_LOCAL/db_backups/INCREMENTAL/
done


content is here
Code:
ls -l /backup/db_backup/INCREMENTAL

Code:
-rw-r--r-- 1 db2inst2 db2iadm1          0 Nov 20 09:56 1.txt
-rw-r--r-- 1 db2inst2 db2iadm1          0 Nov 20 09:56 2.txt
-rw-r--r-- 1 db2inst2 db2iadm1          0 Nov 20 09:57 3.txt

I m really don't understand why this bash is not copying the files .THis is the error .

Code:
./Weekly_Full_Online.sh: line 34: cd: /backup/db_backups/INCRMENTAL/: No such file or directory
mv: cannot stat `1.txt': No such file or directory
mv: cannot stat `2.txt': No such file or directory
mv: cannot stat `3.txt': No such file or directory

Is there any problem with syntax ? i can move the content if use mv out side bash
Moderator's Comments:
Mod Comment Please use CODE tags (not ICODE tags) for full-line and multi-line code segments, sample input, and sample output.

Last edited by Don Cragun; 11-20-2015 at 12:29 PM.. Reason: Change ICODE tags to CODE tags.
# 6  
Old 11-20-2015
INCRMENTAL ?
# 7  
Old 11-20-2015
I updated to INCREMENTAL

now error is different .

Code:
mv: cannot create regular file `/backup_LOCAL/db_backups/FULL/': Is a directory
mv: cannot create regular file `/backup_LOCAL/db_backups/INCREMENTAL/': Is a directory

---------- Post updated at 11:46 AM ---------- Previous update was at 11:41 AM ----------

ignore it .i am working .let me share final out put .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated! for mpdir in... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

2. UNIX for Dummies Questions & Answers

Unable to list folder contents

I'm unable to list the contents of a directory once I move into it. I have full permissions on this directory (called "Scripts" in the below example). The scenario is shown below in detail: Command 'ls' works fine to begin with: 1: pmn@linuxhost /home/pmn > cd /opt/smt/proiv 2:... (4 Replies)
Discussion started by: pmn
4 Replies

3. Shell Programming and Scripting

Copy contents of whatever's loaded into the CD drive

Hello everyone, I have about 1500 compact discs of seismic data that I need to retrieve and place onto the hard drive so that I can index and process them. The data was generated at 20 seismic stations and each disc has a been assigned unique name. The name is NOT necessarily what is on the... (7 Replies)
Discussion started by: ws6transam
7 Replies

4. Shell Programming and Scripting

Need help to copy contents of a file

Hi, I am stuck up with a problem of copying the contents of a directory where one of the folder name is changed daily. Problem: I have the folder structure as: RefWorlds2/LINGCC4_X64/odsdev/odessy/UTI/621GA_build_xxx/.../.. In the above path the build number (xxx) will be changed... (3 Replies)
Discussion started by: SathaKarni
3 Replies

5. Shell Programming and Scripting

copy the contents between two keywords to a new file.

Hi All, I want to edit my gate level netlists by searching for the content between two patterns eg: ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X ), .VDD(1'b1), .VSS(1'b0)); ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X ),... (6 Replies)
Discussion started by: naveen@
6 Replies

6. Shell Programming and Scripting

copy contents of one column in another

Hi, I want to pick contents of a column in a file and copy the contents of this to other column. awk can be used for this, but the number of fields are higher so awk will not help. Any other way to do this. e.g following file has some contents a follows a,b,c,d,e,f,9,0 i need... (4 Replies)
Discussion started by: raman1605
4 Replies

7. Shell Programming and Scripting

Copy selected contents from file

I want to capture contents of a file between 2 strings into another file for eg all lines in between the keywords "start log" and "end log" should be copied into another file (4 Replies)
Discussion started by: misenkiser
4 Replies

8. UNIX for Dummies Questions & Answers

copy folder contents

I need to make a new dir in side the dir lab5 the new dir is called testLab5 without changing directories copy all files from your lab5 directory into your testLab5 directory then i have to without chaning directories and using exactly one command remove all files that start with the... (1 Reply)
Discussion started by: robsk8_99
1 Replies

9. UNIX for Dummies Questions & Answers

How to Copy Contents from CD to Hard disk

Hello all.. Iam New to Unix Environment. I need to copy .cpio file from CD to a Folder on Sun 5.8 Box. Can anyone give me the commands to execute this ?.. Thanks in advance Ron (4 Replies)
Discussion started by: vr76413
4 Replies

10. UNIX for Dummies Questions & Answers

Unable to view contents of a directory

Hi, first post here be gentle. Very new to Unix. Using HP-UX 10.20 I CD into a remote directory on one machine $ cd /net/remote hostname yet when I do an ll in this directory none of the contents appear. It just is empty. when I do the same command from another machine, $ cd... (13 Replies)
Discussion started by: maddave
13 Replies
Login or Register to Ask a Question