Finding which file is missing

I was hoping someone ould help me with the following.

I have 2 files in a directory FILEA and FILEB. i am running a process on these 2 files but before the process can run both FILEA and FILEB need to be present.

If one or both the files are missing i need to know what file(s) is(are) missing. I am not entirely sure how to go about this problem with out using the 'test' command several nested if statements... i am sure there must be a better solution could anyone assist.

Thanks for your help.

What's the problem with doing nested if ?

if [ ! -f $FILEA ]
then
     if [ ! -f $FILEB ]
     then
          echo "Neither file exists"
     else
           echo "File A does not exist but file B does"
     fi
else
    if [ ! -f $FILEB ]
    then
          echo "File A exists but file B does not"
    fi
fi

I was hoping someone could expand on this for me as it could be useful.
How would you do teh below but for different file names.

i.e. say on one day FILEA.TXT is called filea.txt, or FiLeA.tXT or even fIlEa.TxT. Say the case case changes but not the file name. so if the file being checked was always the same name but differed only it uppercase or lowercase how could you do a seach so file would be picked up irrespective of the case

do a

>man tr

and you will find out about its ability to translate characters all to one case as in the following

tr -s '[:upper:]' '[:lower:]'

could you give me an example as my skills are pretty poor
have chacked man tr but am confused as to how i would use to process a file irrelevant of its case...

Plus tr only appears to accept input from stdin but in above example the inputs will be filea and fileb so am even more confused

any help

> file1="AbCdEf"
> file1a=$(echo "$file1" | tr [A-Z] [a-z])
> echo $file1a
abcdef

So, if you translate the filename to all lowercase, then do your comparisons, I think you will be in good shape.

But how can you declare:
file1="AbCdEf"

as you dont have have a clue what file 1 would be as it could be "ABCDEF", "aBcDeF" or what ever the user calls it.

so th initial problem i have is how to actually search for the file (i.e declare it in the script) and secondly how to rename the file to all lowercase so that it can then be processed.

Does that make sense and can you assist this wanna be scriptor

files in my directory

> ls
./  ../  ABCDEF.txt  AbCdEf.txt  AbcdEf.dat  abcdeF.txt  match_names*  text_review

the program/script

> cat match_names 
#! /bin/bash

ls *.txt >text_review

while read zf
   do
   file2=$(echo "$zf" | tr [A-Z] [a-z])
   if [ "$file2" = "abcdef.txt" ]
      then 
      cat "$zf" 
   fi
done <text_review

execute the program.script

> match_names 
You are inside ABCDEF.txt file
You are inside AbCdEf.txt file... yes...
You are inside abcdeF.txt  .. congrats

everybody thankyou for your help. There is nothing wrong with the nested if statements just wondered if there was a more neat way.

Following on from chachabronsons question i do not understand the above, although i am intrigued as to how it would work.
The above example does not make sense for the following:

FILEA = TestFile1.txt (how would this be declared so the file could be in any case upper, lower or mixture)

FILEB = TestFile2.txt (how would this be declared so the file could be in any case upper, lower or mixture)

if [ ! -f $FILEA ]
then
if [ ! -f $FILEB ]
then
echo "Neither file exists"
exit
else
echo "File A does not exist but file B does"
exit
fi
else
if [ ! -f $FILEB ]
then
echo "File A exists but file B does not"
exit
fi
fi

Therefore if both files present run process

Hi.

Here is an alternate solution that uses the option in grep to ignore case distinctions:

#!/bin/bash -

# @(#) s1       Demonstrate filter ignoring case.

echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) grep
echo

FILES="ABCDEF.txt AbCdEf.txt AbcdEf.dat abcdeF.txt"
rm -f $FILES

touch $FILES
echo " Files currently extant:"
ls

echo
echo " Result of filtering, ignoring case:"
ls -1 |
grep -i abcdef.txt

exit 0

Producing:

% ./s1

(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 2.05b.0
grep (GNU grep) 2.5.1

 Files currently extant:
ABCDEF.txt  AbCdEf.txt  AbcdEf.dat  abcdeF.txt  readme.txt  s1

 Result of filtering, ignoring case:
ABCDEF.txt
AbCdEf.txt
abcdeF.txt

Best wishes ... cheers, drl

You could try

FILEA='[Tt][Ee][Ss][Tt][Ff][Ii][Ll][Ee]1.[Tt][Xx][Tt]' 

if [ ! -f $FILEA ]
then
        echo file does not exists
else
        echo file exists
fi

but there may be issues if multiple files are matched.