I am on linux and I am supposed to receive 3 files. If any of the files are not received I need to identify the missing file and throw it out in a variable.
I have put in something like this
if [[ -a $file1 ]]
then echo "file $file1 was found"
else
echo "ERROR: file $file1 was not found!!!"
##### set a variable here ##############
fi
if [[ -a $file2 ]]
then echo "file $file2 was found"
else
echo "ERROR: file $file2 was not found!!!"
##### set a variable here ##############
fi
if [[ -a $file3 ]]
then echo "file $file3 was found"
else
echo "ERROR: file $file3 was not found!!!"
##### set a variable here ##############
Is there a way I can capture each file in a variable and throw out the missing file after all the checks are completed?
What do you mean by "capture each file in a variable"? You already have each file's pathname in a variable. You can't put the contents of a file that was not found in a variable (unless you just want to set a variable to an empty string).
I assume that you are asking for our help in setting variables (since you have put those comments in bold text), but I have no idea what you intend to do with those variables???
How do you "throw out the missing file"? If a file is missing isn't it already gone???
What i was looking for was to find out which file is missing by assigning a variable in the check condition for each file and if any of the variables have a value exit it out by throwing which file was missing based on the variable.