I'm trying to grab the first file matching a pattern and use that in a statement. Using the same steps as found in How can I get the first match from wildcard expansion? I wrote the following:
#!/bin/bash
files=("*.sql")
firstfile=${files[0]}
echo $firstfile
echo "The first file is $firstfile"
When I run this, the output is:
sqlfile.sql
The first file is *.sql
Why does the value of $firstfile
change based on the context?