Looking on how to write Unix shell script for filename pattern matching? There’s several way you can write it using regular expression technique in scripting.
Let’s say you have a scenario where you want to perform certain command execution e.g file processing if certain filename exist in certain folder.
Here’s the example of a simple Unix shell script you can use to accommodate your file processing scenario.
for file in ./*_new.txt ; do
if [ -e "$file" ] # Make sure file exists and isn't an empty match
echo "Filename with pattern _new.txt exist"
echo "Filename with pattern _new.txt not exist"