Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bash - check for spaces

Posted on 2007-04-05
4
Medium Priority
?
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 total points
ID: 18861019
echo "$jnickname" | grep ' '
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

610 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