Hi, I'v just started learning about bash scripting, however I already have a problem. I'm trying to use regular expressions to validate user input and if it's correct, than put it into my file:
Code:
if echo "$INI $LIM $STI $VEC $NMD $MSU" | grep -q -i ^[B-Z]+[[:space:]][a-z][[:space:]][a-z][[:space:]][a-z][[:space:]][a-z][[:space:]][a-z]$; then
echo -e "$INI $LIM $STI $VEC $NMD $MSU\t" >> $FILE
The problem is - if I have a line like "a a a a a a" (where the first letter logically isn't right) it says, that everything's fine and writes the output to the file - I don't understand it. As I understood, it should be checking if the first character is from capital 'B' to capital 'Z' and find at least one match. Perhaps I'm not doing it correctly (I didn't change the rest of REs, just the first variable, cause obviously there's no point if even the first doesn't work). What I'm trying to achieve is this output form (I'll explain it in example):
Somename Somesurname Style 18 16.08.2007 23.45
Hope, you can help me.