This question already has an answer here:
I have an executable which creates either
file2 along with other files. I am trying to write a shell script which should output the latest created file. If the executable creates
file1, the output should be
file1. Please note that I already have both
file2 exists in the directory along with other files. The executable overwrites it.
If there are no file1/file2 exist, below script works but this doesn't work if both
if [ -e "file1" ]; then output="file1" else output="file2" fi