Avoding the ERROR message while using find,move commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Avoding the ERROR message while using find,move commands
# 1  
Old 01-19-2015
Avoding the ERROR message while using find,move commands

Hi All,

We just need to move a set files to a Archive location and then delete the files older than 1 day.

I used the below commands respectively.

When the file exist it is working. But when the file doesnt exist, in the ouptput log file it is showing "NO MATCH". How to avoid this in the output log file as it seems to be sort of error message.

Code:
mv ${LOG_HOME}/cust_delete*.out  $ARCH_LOG_HOME
 
find ${ARCH_LOG_HOME} -type f -name "cust_delete*.out" -mtime +1 -exec rm {} \;

Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 01-19-2015 at 03:40 AM.. Reason: code tags
# 2  
Old 01-19-2015
You can redirect STDERR to the bucket with adding the following at the end of the same line that gives you the error:
Code:
2> /dev/null

The line with find should give no error - you can also just check if the file exists and only then do the mv.

Last edited by zaxxon; 01-19-2015 at 03:54 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find Null values in Columns and fail execution by displaying error message

Hi All, I am new to shell scripting. I have a requirement as part of my job to find out null/empty values in column 2 and column 3 from a CSV file and exit the further execution of script by displaying a simple error message. I have developed a script to do this by reading various articles... (7 Replies)
Discussion started by: tpk
7 Replies

2. Red Hat

Find and move

Greetings.... Trying to find and move the 30 days old logs #!/bin/bash DATE=`date +%d-%b-%Y` STATUSLOG="$HPATH$DATE-E3Backup.log" HPATH="/ABC/Websphere/" HT=`hostname` BKUPSTR="/ABC/Websphere/$HT/" echo "Moving of old logs Started on $HT " >> $STATUSLOG find... (2 Replies)
Discussion started by: manju98458
2 Replies

3. Shell Programming and Scripting

Find and move

Hello All, /storage3 /storage4 I have written a shell script to locate files older than 7 days in /storage4 folder and move to /storage3.At the same time it will take output as number of files moved and log in a .txt file. It will also find files in /storage3 older than 90 days and remove... (4 Replies)
Discussion started by: Siddheshk
4 Replies

4. UNIX for Advanced & Expert Users

find -exec with 2 commands doesn't work (error incomplete staement)

Hi Gurues, I need to modify an existing script that uses find to search a folder, and then move its contents to a folder. What I need to do is run gzip on each file after it's moved. So, I ran this little test: Put a ls.tar file on my $HOME, mkdir tmp, and then: virtuo@tnpmprd01: find .... (3 Replies)
Discussion started by: llagos
3 Replies

5. Shell Programming and Scripting

Suppressing the terminated message from pkill & killall commands in a bash script

Hi all, I've been pulling my hair out with this problem for 3 days:wall: now without success any help would be massively appreciated. Basically the script is used to shutdown a rails server so a new IP address can be assigned, the shutdown part is taken care of in function_one using the... (2 Replies)
Discussion started by: danmc
2 Replies

6. Shell Programming and Scripting

Move xml files from unix to message queue.

Hi, I need to move the XML files from the UNIX to the message queue. Please help me out to write the code.. Thanks, Mohana Krishnan (0 Replies)
Discussion started by: krishnan_6015@y
0 Replies

7. AIX

Move Xml files from AIX machine to message queue.

Hi, Im new to message queue... I need to move the xml files from the AIX server to the message queue. Please help me out to write the code.. Thanks, Mohana Krishnan (0 Replies)
Discussion started by: krishnan_6015@y
0 Replies

8. UNIX for Advanced & Expert Users

find and move

Hello I am new to this board. I was looking for a one line command to find the oldest 10,000 files in a directory and move them. I tried such things as: find . -type f | ls -ltr | head -n 10000 -exec mv {} directory/ \; find . -type f | ls -ltr | head -n 50 | xargs mv directory/ \; ... (7 Replies)
Discussion started by: natasha80
7 Replies

9. Solaris

Error Message: find: cannot open /: Stale NFS file handle

I am using the "find" command below and it respond with the error message " find: cannot open /: Stale NFS file handle" what does it mean? what can I do about it? Need advice, thanks. below are the command that I enter, the respond and the error message: root@ScripServer:/# find / -name... (1 Reply)
Discussion started by: ezsurf
1 Replies

10. Shell Programming and Scripting

find move

Hello folks. I have read the forum here, almost came close to using some of the hints but too much info so I need a little nudge. OBJECTIVE: I want to write a script that looks at certain type of files, than move those selected files to another directory, however, keeping the structure (PATH)... (4 Replies)
Discussion started by: saswerks
4 Replies
Login or Register to Ask a Question