LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-19-2009, 05:16 PM   #1
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Rep: Reputation: 15
While not null


Can bash do this? I've been trying to find a solution for a while now to no avail... basically looking for the equiv to this, but with just "not null":

while [ $ans != "xY" ]; do
....
done
 
Old 11-19-2009, 05:24 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
while [ "$ans" ]; do

or

while [ -n "$ans" ]; do

should work I think.. You just want it to continue as long as $ans is *something* right?

Sasha
 
Old 11-19-2009, 06:10 PM   #3
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Original Poster
Rep: Reputation: 15
I want it not not error out if the entry is blank, or not proceed if the entry is blank
 
Old 11-19-2009, 06:21 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Right. Did you try what I wrote? It should exit the while..done loop if $ans is an empty string, and continue with the rest of the script. It won't error out.

I'm figuring you have some code in between the while and the done that is affecting the value of $ans; so, when $ans ends up being empty, the loop stops looping.

Sasha
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is meant by " file > /dev/null 2>&1 </dev/null " attockonian Linux - Newbie 5 06-30-2006 10:51 PM
JavaScript:: alert(node) shows null, but node != null taylor_venable Programming 1 05-01-2006 09:51 PM
fstab-sync: error: libhal_ctx_init_direct: (null): (null) rpz Linux - Hardware 1 11-01-2005 05:42 AM
1> /dev/null 2> /dev/null elyk Programming 9 09-20-2004 05:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration