[ -f $num3 ]
Doesn't make sense as you're applying the split+glob operator to the content of
[ -f "$num3" ]
Would check whether the
$num3 path (absolute if it starts with a
/, relative to the current working directory if not) resolves to a file that is of type regular or a symlink to a regular file.
If you want to check whether
$num3 relative to a given directory is a regular file, just use:
[ -f "$dir/$sum3" ]
You may want to check beforehand that
$sum3 doesn't start with a
/ or doesn't contain a
Note that if
/, that approach will not work on systems that treat
//foo/bar paths specially. So you may want to treat the
dir=/ case specially.
case $dir in
[ -f "$file" ]
To check that
$num3 is a relative path (to a regular file) of any directory in the directory tree rooted at the current directory, best would be to use
if (($#files > 0)); then
echo "Success: $#files such file(s) found"