Multiple Find Conditions in IF Statement - UNIX

When I try the below if Condition with single condition its working fine.
But when I try to Club both its working . But giving wrong results.

In my case
cond1 = -f ${filename1} = true
cond2 = -f ${filename2} = true

But Cond1 & Cond2 is resulting in False ??? Please advise

filename1='/home/abc????????'
filename2='/home/yyy????????'
 
if [[ -f ${filename1} && -f ${filename2} ]]
then
echo 'files Available' >>${log}
else 
echo 'Files Not Available' >>${log}
fi

Thank you :slight_smile:

I don't see anything wrong with that, but then, you haven't said what your shell is. Those ????'s will expand, by the way, unless you put the filenames in "quotes". Try -a instead of && too.

Its Korn Shell. I really dont understand why this is not giving correct results ... :frowning:

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Did you try adding quotes like I suggested, so the ????? don't accidentally expand into one or more different filenames?

Thank you Corona688 for your help.

FYI - Same code worked. I tried creating a new file. I got it ... Probably their where some bad characters (Edior issues)