Error while moving files and deleting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while moving files and deleting
# 1  
Old 11-19-2015
Error while moving files and deleting

Team i am trying to delete files which are older than 1 day from 1 path (assuming already files are existed ) .

From another path we are trying to move files .like below .While executing this i m getting this error .

Code:
mv: cannot stat `/backup/db_backups/FULL/*': No such file or directory

But i am sure /backup/db_backups/FULL folder is existed and its bash ..

Any suggessions ??

evn rm command ran for the first time properly but 2nd iteration onwords its not removing files though we have older files


Code:
#PURGE OLD BACKUPS from /backup_LOCAL/db_backups

cd /backup_LOCAL/db_backups/FULL/
find /backup_LOCAL/db_backups/FULL -mtime +1 -exec rm -rf {} \;

# MOVE BACKUPS TO backup_LOCAL/db_backups FROM /backup/db_backups/

cd /backup/db_backups/FULL
mv /backup/db_backups/FULL/*.* /backup_LOCAL/db_backups/FULL/


Last edited by Don Cragun; 11-19-2015 at 05:44 PM.. Reason: Fix CODE and ICODE tags.
# 2  
Old 11-19-2015
Post the result of ls -la /backup/db_backups/FULL/.
# 3  
Old 11-19-2015
Code:
mv: cannot stat `/backup/db_backups/FULL/*': No such file or directory

This occurs when the shell can not expand the * to any meaningful file name. It is not complaining about the directory FULL not existing but about * not being a file.
If all files matching that pattern has been moved or deleted previously, the shell does not have any to expand later on and it passes the * to the command.
# 4  
Old 11-20-2015
Output of ls -la

Code:
4096 Nov 19 10:30 .
4096 Nov 15 05:45 ..
Nov 19 10:30 X.gz
Nov 19 10:30 y.gz
Nov 19 10:30 yz.txt
Nov 19 10:30 1.txt

so it has both .txt and .gz files, suggest some aleternative how can we make this successful ?

---------- Post updated at 08:26 AM ---------- Previous update was at 07:49 AM ----------

I see that mv command is working manually but if i add it in bash and run .sh its giving error .

Code:
mv: cannot stat `/backup/db_backups/INCRMENTAL/*.*': No such file or directory

How can we overcome this error ?
Moderator's Comments:
Mod Comment Please use CODE tags (not ICODE tags) when displaying full-line and multi-line code segments, sample input, and sample output.

Last edited by Don Cragun; 11-20-2015 at 12:05 PM.. Reason: Change ICODE tags to CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In php, Moving a new row to another table and deleting old row

Hi, I already succeed moving a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). But it can't delete the old row. Please help me with the script. my php script: INSERT INTO... (2 Replies)
Discussion started by: jazzyzha
2 Replies

2. Shell Programming and Scripting

Moving new row and deleting old row to another table

Hi, I want to move a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). I already use this script but doesn't work as I expected. CHECK_KEYWORD="$( mysql -uroot -p123456 smsd -N... (7 Replies)
Discussion started by: jazzyzha
7 Replies

3. AIX

Moving Hidden files to normal files

I have a bunch of hidden files in a directory in AIX. I would like to move these hidden files as regular files to another directory. Say i have the following files in directory /x .test~1234~567 .report~5678~123 .find~9876~576 i would like to move them to directory /y as test~1234~567... (10 Replies)
Discussion started by: umesh.narain
10 Replies

4. Shell Programming and Scripting

Finding files with wc -l results = 1 then moving the files to another folder

Hi guys can you please help me with a script to find files with one row/1 line of content then move the file to another directory my script below runs but nothing happens to the files....Alternatively Ca I get a script to find the *.csv files with "wc -1" results = 1 then create a list of those... (5 Replies)
Discussion started by: Dj Moi
5 Replies

5. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

6. Shell Programming and Scripting

moving the files in a.txt files to a different directory

HI All, I am coding a shell script which will pick all the .csv files in a particular directoryand write it in to a .txt file, this .txt file i will use as a source in datastage for processing. now after the processing is done I have to move and archive all the files in the .txt file to a... (5 Replies)
Discussion started by: subhasri_2020
5 Replies

7. Shell Programming and Scripting

Need help with shell script for moving/deleting/renaming files

Hi. I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next. Here's an example: /var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Discussion started by: aflower
4 Replies

8. Shell Programming and Scripting

Getting unusual error - moving files to another directory

Dear experts, Im having an unusual problem and its been giving me a bad headache. I have the script below #!/usr/bin/sh -x ticketinputdir=/IN_DATA1/tickets ticketoutputdir=/IN_DATA2 YDAY=`env TZ=A12B date '+%Y%m%d'` for i in INA INB INC IND INE do mkdir $ticketoutputdir/$i/$YDAY... (4 Replies)
Discussion started by: aismann
4 Replies

9. Shell Programming and Scripting

deleting particular lines and moving a line up using perl/sed

Hi, I need convert a dump file in the following format : (please note that line numbers are provided for easy look) Original file: 1 2007-10-2482.90 No trade 0 0.00 100000.00 2 100000.00 3 0.00 4 HOLD 5 2007-10-2589.75 Bought 1114 1114 100000.00 0.00 ... (5 Replies)
Discussion started by: sabyasm
5 Replies

10. Shell Programming and Scripting

Suppres error message when moving files from empty source folder

Hi, I would like to write a shell script that moves files from one folder to another without retrieving the error 'can not acces/find file or folder' when the source folder is empty. Any ideas, Thx in advance, Steven. (2 Replies)
Discussion started by: Steven
2 Replies
Login or Register to Ask a Question