Hello All
I have a set of files, each one containing some lines that follows that regex:
regex='disabled\,.*\,\".*\"'
and here is what file says about each files:
file <random file>
<random file> ASCII text, with CRLF line terminators
So, as an example, here is what a file ("Daffy Duck - The Marvin Missions (USA).cht" is its name) says:
disabled,C283-3D6F,"Invincibility"
disabled,DFBD-1DA4,"Start with 1 life"
disabled,DBBD-1DA4,"Start with 9 lives (don't set lives in options menu)"
disabled,49BD-1DA4,"Start with 25 lives (don't set lives in options menu)"
disabled,9FBD-1DA4,"Start with 51 lives (don't set lives in options menu)"
disabled,DDB3-3404,"Infinite lives"
disabled,DDA8-4466,"Extra lives cost $500"
disabled,DFA8-4466,"Extra lives cost $1,500"
It's not visible on this forum, but I have a character encoding problem on the `'` on lines 3-5
In order to check the syntax of each file, I wrote a small bash script (see below) that check each line against the regex above. But due to this small encoding problem, my script echoes those lines although they match the regex.
My script:
#!/bin/bash
regex='disabled\,.*\,\".*\"'
for f in *cht; do
while read line; do
if [[ ! "${line}" =~ ${regex} ]]; then
echo "$f - $line"
fi
done < "$f"
done
exit 0
stdout:
Daffy Duck - The Marvin Missions (USA).cht - disabled,DBBD-1DA4,"Start with 9 lives (dont set lives in options menu)"
Daffy Duck - The Marvin Missions (USA).cht - disabled,49BD-1DA4,"Start with 25 lives (dont set lives in options menu)"
Daffy Duck - The Marvin Missions (USA).cht - disabled,9FBD-1DA4,"Start with 51 lives (dont set lives in options menu)"
Any advices to get rid of those (replacing is not an option)? Thank you for reading.