?
Solved

Bash - check for spaces

Posted on 2007-04-05
4
Medium Priority
?
354 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 85

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 85

Accepted Solution

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

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

862 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