I have a simple syntactically wrong command like this that is meant to be run on Unix/Linux hosts
$ echo "first string $PATH" > out.lst $ ECHO second string %PATH% > out.lst
The first line will succeed and fill the out file, whilst the second will fail emptying the previously filled file.
I'm trying to find a way to preserve the content of the file in case an error occurs in calling some command whose output is meant to override the file.
The use case is a bit strange: I'm trying to write a portable SQL script for Oracle SQL*Plus that is meant to call commands from the underlying OS that may be either Linux or Windows. Being not possible to detect the OS, I'm calling both the commands for the two platform and trying to make the things work just by not raising the exception.
On windows, both lines will succeed and the second will override the first. On Linux, the second line will fail, but I want to preserve the content of the file.