I need a bash script to read a file line by line. If the regular expression matches, highlight this line.
script:
#!/bin/bash
echo "Start!"
for line in $(cat results)
do
regex = '^[0-9]+/[0-9]+/[0-9]+$'
if [[ $line =~ $regex ]]
then
echo $line
fi
done
It prints the contents of the file, but shows this warning:
./script: line 7: regex: command not found
Where is the mistake?
source
share