Question : Can I have a shell script continue after failure on a line?

I'm quite new to Bash shell scripting, so I don't know how to add this functionality.  I have a shell script that runs an Oracle export which creats multiple, similarly-named output files (exp1.dmp. exp2.dmp, etc.).  I then have the script rename them to include the current month and day in the output file name (exp1_1230.dmp. exp2_1230.dmp, etc.).

Now, between those two steps, I would would like to copy them to my test server, but I want the rename to happen whether the copy to the test server succeeds or not.  I also want the copy to the test server (with the "-f" switch to over-write) to happen before the rename, so I just have one set of these files on the test server that gets overwritten each day with the newer files.

Is there a way in a Bash shell script to have it continue regardless of a possible failure on a line like:
cp -f exp?.dmp ...

Or, should that copy be in a different script that is called from this script?  Or, is this not possible with shell scripts?  (I have to admit that I like the DOS/Windows batch files that usually continue past errors on a line.)

I realize that I could do the copy as last step instead, but then I have to deal with the uniquely-named files, and I will end up with multiple copies from multiple days on my test system, unless I add more logic to delete the older files first.

Answer : Can I have a shell script continue after failure on a line?


In shell script (bash & ksh), if a copy (cp) command fails, the script does NOT exit, it just issues an error.
Random Solutions  
 
programming4us programming4us