I wanna check if there is special character in a line inside a text file using Regex in shell script. assume there is sentence "assccÑasas" how to check if there is 'Ñ' inside the line, so it should be output as error instead. I also wanna check if there is symbol such as '/' or '^' or '&', etc
my code :
VALID='^[a-zA-Z_0-9&.<>/|\-]+$' #myregex
checkError(){
if [[ $line =~ $VALID ]]; then
echo "tes"
else
echo "not okay"
exit 1
fi
}
while read line
do
checkRusak
done < $1
so the example like if there is sentence "StÀck Overflow;" then it will output error. if there is sentence "stack overflow;" still output error. but if only "stack overflow" (no symbol or special character), it will output "test"
so far it can check for symbol ('/' or '\' etc) but still problem in special character.
Any help really appreciated, thank you in advance