Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignoring error messages

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Hi,

Say in a script I put "mv /app/myfile.txt /app/myfile2.txt"

and myfile.txt doesn't exist. And I put that script in a crontab....

When the crontab runs it sends out an error saying mv: cannot access /app/myfile.txt

Is there a switch that I can use with "mv" so that it just ignores that? (i.e. if it can't find the file then it doesn't care).

Thanks,

Chris
 
[ -f /app/myfile.txt ] && mv /app/myfile.txt /app/myfile2.txt

Hope This Help
PH.
 
Yep. Thanks for both your answers. I'm using the second although slightly modified.

Thanks,

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top