I have a file with a list of names. for each name I want to find a file that starts with that name and ends with a certain suffix. I wrote a short bash script but am not getting any output from the find command
#!/bin/bash
file="/my_folder/list_of_names"
while read var
do
echo $var
find /folder/of/files/ -name "${var}*" -and -name *.bam
done <"$file"
The list of names gets printed to the screen correctly thanks to the echo command. If I set "var" manually to equal one of the names from the list and run the find command with the parameters it returns the file I'm looking for but within the script it doesn't work.