Solved

Bash - check for spaces

Posted on 2007-04-05
4
340 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:rares_dumitrescu
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18857027
while echo $jnickname | grep ' '
0
 

Author Comment

by:rares_dumitrescu
ID: 18857182
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
0
 

Author Comment

by:rares_dumitrescu
ID: 18858534
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>
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18861019
echo "$jnickname" | grep ' '
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now