I am new to shell scripting and I can't figure it out on how to check the filenames if it has a specific string.
For example, the filenames are in xyz.abc.d.CSV format. How can I check if the filename contains that string?
Here is my code:
ls *.CSV | while read filename; do
if [ filename == "*abc*"]; then
echo "Found it"
else
echo "No abc"
done
ls *.CSV list all the files with a .csv format. while reading the files, the code will compare if the filename have an "abc" string. if yes, the system will print "Found it", else, the system will print "No abc".
ls *.CSV | grep -E "abc"echo *.CSVinstead ofls.