Link to home
Start Free TrialLog in
Avatar of rares_dumitrescu
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
Avatar of ozo
ozo
Flag of United States of America image

while echo $jnickname | grep ' '
Avatar of rares_dumitrescu
rares_dumitrescu

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
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
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial