Solved

Bash - check for spaces

Posted on 2007-04-05
4
343 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

830 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