I would like a little help on writing a if statement.
What i have so far is:
#!/bin/bash
FILE1=path/to/file1
FILE2=path/to/file2
echo ${FILE1} ${FILE2}
if [[ ! ( -f $FILE1 && -f $FILE2 ) ]]
then
echo file1 and file2 not found
else
echo FILE ok
fi
but as for prep work I'd like to modify it to output which file is found.
so more along the line of this:
if file1 is found then echo file1 found
But i would need the script to look for both 1 and 2 if 1 doesn't exist.
Thank you I was just about to update this as i forgot i'm using "or" not "&"
Thanks for your help guys!
---------- Post updated at 03:45 PM ---------- Previous update was at 03:41 PM ----------
I do have one more question for you guys....
If it finds file1 or file2 can you make it into a variable to use for the rest of the script? which ever one it finds. in the script i'm making there should only be 1 of the two that exist.
The first part that I posted will be used to to check the control of the script and exit if both files exist before the the other part checks to see which file is actually valid.
something along the line of this:
if ([ -f $FILE1 ] && [ -f$FILE2 ])
then
echo both files exist script is exiting
else
echo one or more files missing
fi