i have some files in the directory:
ABC_file1_2020-10-01.txt
ABC_file1_2020-01-02.txt
ABC_file2_2020-11-01.txt
ABC_file2_2020-11-02.txt
CDE_file1_2020-11-01.txt
CDE_file1_2020-11-02.txt
CDE_file1_2020-11-03.txt ....
I want to use bash script in centos and find the files with prefix as ABC and date greater than 2020-11-01. i have written code like this: to find if prefix matches with file
#!/usr/bin/bash
read -p "enter prefix of a file : " prefix
for file in *; do
if ["$file" = *"$prefix"*]; then
echo $file
fi
done
since I am new to this, I wanted to do it step by step and first wanted to find the file name that matches with the given prefix and later I thought of doing the condition for checking the date inside the if condition. but I don't understand where I have gone wrong. I am getting error in line 7. let me show the screen shot of error. here it is, error at line
I am new to this scripting. it would be an immense help if someone helps me with this error and finding the files with the prefix and the date greater than 2020-11-01.