I am trying to use the if condition in shell script to check whether some files (starting with similar names) exist or not in the working directory. My problem is I have more than one file viz. "A1.txt", "A2.txt", "A3.txt" etc in my working directory. Now my question is, is there a way to check for files with the part of the string of the file name. So if the script finds at least one file with name starting with "A" then it prints that file found of there is no file with file name starting with "A" it does not print so. My attempt is the following :
if [ -f "A*.txt" ];
then
echo "Files exist."
else
echo "Files do not exist"
fi
But it does not work and returns "too many arguments". Is there a way out?