rares_dumitrescu
asked on
Bash - check for spaces
Hello, how can i repeat an dialog until there are no spaces in the word that is read from the dialog ?
example:
dialog --title "EvoPanel - getmuh v1.5" \
--inputbox "\nWrite the nickname\n" 13 50 "$jnickname"
jnickname=`cat $tempfile`
while -nickname has spaces in it-; do something
so if i write " blah" the while will turn on and ask me again, until i remove the spaces
example:
dialog --title "EvoPanel - getmuh v1.5" \
--inputbox "\nWrite the nickname\n" 13 50 "$jnickname"
jnickname=`cat $tempfile`
while -nickname has spaces in it-; do something
so if i write " blah" the while will turn on and ask me again, until i remove the spaces
while echo $jnickname | grep ' '
ASKER
while [ -z $jnickname ] || [ echo $jnickname | grep ' ' ]; do
cat /dev/null > $tempfile
dialog --title "EvoPanel - getmuh v1.5" \
--inputbox "\nError: You cannot have a null nickname.\n\
Please try again.\n" 12 50 "$jnickname"
jnickname=`cat $tempfile`
done
but it does not say anything .. it forks if i type: aa aa
cat /dev/null > $tempfile
dialog --title "EvoPanel - getmuh v1.5" \
--inputbox "\nError: You cannot have a null nickname.\n\
Please try again.\n" 12 50 "$jnickname"
jnickname=`cat $tempfile`
done
but it does not say anything .. it forks if i type: aa aa
ASKER
i was wrong, if i type aa aa it does not work, but if i tipe <space><space>aa it works, or aa<space><space>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.