I've had this question for awhile. In my work that uses bash scripting there are many instances where I have to save a filepath to a variable for use in a later command. We use files with suffixes T1w, T2w, and mask and in many cases we have a preferential file (e.g. T1ws) but, in their absence, will use another file (e.g. T2w). I usually use the following bash syntax to search for the appropriate file and save it to a variable (given I am searching in my current directory):

```
if [ -f xxx_T1w ]; then
  var1=xxx_T1w
elif [ -f xxx_T2w ]; then
  var1=xxx_T2w
fi

```

So ok fine, it works but I was always curious if there was a way in bash to code something like: *If one of two given files exists, take the one that exists, and if both exist, take the first file.*
I'm horrendous at pseudocode but maybe something like:

```
if [ -f file_T1w ] || [ -f file_T2w ]; then
  var1=existing file
fi

```

I'm reusing this code a lot and sometimes the `elif` statements get pretty long if have a longer list of preferential files we can walk through and I've long wanted to know if there was a more compact way to do this.