$ find ./ -name "AABE*" ## this returns nothing
$ echo $?
0
$ find ./ -name "AWGT*" ## this returns locations of were files matching the criteria
./Atempt3A/AWGT-modified.txt
./Atempt3A/test_will_nov2022/AWGT-modified.txt
./Attempt5_Dec_2022/scripts/AWGT-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/AWGT-modified.txt
$ echo $?
0
$ find ./ -type f -name "AWGT*" -o -name "SLIN*" -o -name "AABE*" -o -name "AMDM*" -o -name "ARDE*" -o -name "WTHC*" ## this returns locations of were multiple files matching the criteria
./Atempt3A/AMDM-modified.txt
./Atempt3A/AWGT-modified.txt
./Atempt3A/test_will_nov2022/AWGT-modified.txt
./Atempt3A/WTHC-modified.txt
./Attempt2/164_sites/env_scripts/AMDM-modified.txt
./Attempt2/164_sites/env_scripts/WTHC-modified.txt
./Attempt2/179ish_sites_20220914/AMDM-modified.txt
./Attempt2/179ish_sites_20220914/WTHC-modified.txt
./Attempt5_Dec_2022/again/ARDE-modified.txt
./Attempt5_Dec_2022/again/SLIN-modified.txt
./Attempt5_Dec_2022/scripts/AMDM-modified.txt
./Attempt5_Dec_2022/scripts/AWGT-modified.txt
./Attempt5_Dec_2022/scripts/WTHC-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/AMDM-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/ARDE-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/AWGT-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/SLIN-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/WTHC-modified.txt
$ echo $?
0
What I want is the output to show something like:
cannot find "AABE*" , or something to this affect
can this be done?
related to this question but mine is slighly different
Can I make `find` return non-0 when no matching files are found?
EDIT1-Answer
$ find ./ -type f -name "AWGT*" -o -name "SLIN*" -o -name "AZZZ*" -o -name "AMDM*" -o -name "ARDE*" -o -name "AQQQ*" | perl -pe '
BEGIN{ our %h; our $error = 0; }
$h{$1}++ if m/(AWGT|SLIN|AZZZ|AMDM|AQQQ)/;
END{
for ("AWGT", "SLIN", "AZZZ", "AMDM", "AQQQ") {
if ($h{$_} == 0) {
$error = 1;
warn "cannot find $_\n"
}
}
exit($error)
}
'
./Atempt3A/AMDM-modified.txt
./Atempt3A/AWGT-modified.txt
./Atempt3A/test_will_nov2022/AWGT-modified.txt
./Attempt2/164_sites/env_scripts/AMDM-modified.txt
./Attempt2/179ish_sites_20220914/AMDM-modified.txt
./Attempt5_Dec_2022/again/ARDE-modified.txt
./Attempt5_Dec_2022/again/SLIN-modified.txt
./Attempt5_Dec_2022/scripts/AMDM-modified.txt
./Attempt5_Dec_2022/scripts/AWGT-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/AMDM-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/ARDE-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/AWGT-modified.txt
./Attempt5_Dec_2022/scripts - added_morefrom_again_folder/SLIN-modified.txt
cannot find AZZZ
cannot find AQQQ