Echo "Hello everybody!"
I need to check whether the input argument of a linux script does comply with my security needs. It should contain only a-z characters, 0-9 digits, some spaces and the "+" sign. Eg.: "for 3 minutes do r51+r11"
This didn't worked for me:
if grep -v '[0123456789abcdefghijklmnopqrstuvwxyz+ ]' /tmp/input; then
echo "THIS DOES NOT COMPLY!";
fi
Any clues?
You are telling grep:
Which would only show you lines that contains neither of the characters above. So a line only containing other characters, like
()
would match, butasdf()
would not match.Try instead to have grep showing you every line that contains charachter not in the list above:
If you find something that's not a number or a letter or a plus, then.