while never ends


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users while never ends
# 1  
Old 12-01-2005
while never ends

Hi

i have question, is this ok in ksh, like

while [[ $true != y || $true != Y ]]
do
something
read true
done

loop runs but never ends even i pass y/Y.
can any body please resolve it
# 2  
Old 12-02-2005
Quote:
Originally Posted by Raom
Hi

i have question, is this ok in ksh, like

while [[ $true != y || $true != Y ]]
do
something
read true
done

loop runs but never ends even i pass y/Y.
can any body please resolve it
Absolutely no idea why it works like this. I sense the problem is with the multiple conditions

[[ $true != y || $true != Y ]]

Instead you could have one condition as below

Code:
while [[ $true !=  "Y" ]]
do
echo "Doing Something"
read true
true=`echo $true|tr [a-z] [A-z]`
done

# 3  
Old 12-02-2005
yaa

[[.......]] alone or as if [[ ....]] is working but with while it never works for me .any way thanks for reply.
# 4  
Old 12-02-2005
Your test condition is always going to be true.

If you enter 'y' for the $true variable then "$true != 'Y'" will be true, if you enter 'Y' for the $true variable then "$true != 'y'" will be true. You need to change || to &&.

Cheers
# 5  
Old 12-05-2005
In addition to what grasper already said: I would change the variables name from "true" to something else, like "continuation_flag" or whatever. "true" is a command and you should not name variables the same.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trimming ends

My files look like this I need to remove the sequence GGGAAA and anything before that I also need to remove the sequence AGCCCTA and anything after that So I will end up with something like this The left side is done but I cannot get the right side correctly. I would like to use... (3 Replies)
Discussion started by: Xterra
3 Replies

2. Shell Programming and Scripting

Grab line regardless of if it ends with tabs or spaces

so i have a data file that has various lines which may or may not end with spaces or tabs. data.file: , \t \t {sample} <spaces> <spaaces> several more spaces.... {"resemble"}, <nospaces> Command i'm using: sed -n 8p data.file | egrep "\],$|\],\ $" or egrep "\],$|\],\ $"... (1 Reply)
Discussion started by: SkySmart
1 Replies

3. UNIX for Dummies Questions & Answers

Joining ends of strings in certain order with repeated ID's

I posted this a few days ago and got some help (Putting together substrings if pattern is matched - Page 2 | Unix Linux Forums | Shell Programming and Scripting) But I am now stuck on an issue that is similar but not the same really. I want to join parts of one line with parts of another line... (8 Replies)
Discussion started by: verse123
8 Replies

4. Shell Programming and Scripting

How to find a file which are not ends with ".zip" and which are ends with "*.log*" or "*.out*"?

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which are not ends with “.zip” and which are contains in the file name “*.log*” or “*.out*”. I know below command to get the files which ends with “.log”; but I need which are not ends with this... (4 Replies)
Discussion started by: Mallikgm
4 Replies

5. Shell Programming and Scripting

Execution of KSH after the Other ENDS

I have couple of scripts which I may have to execute one after the other. The Script1 creates trg files and second sciprt need to look for this trg file and proces further. I read in the forum that (./test1.sh && ./test2.sh) would work. Can you please let me know how do i use this where I need to... (3 Replies)
Discussion started by: Sukruth Kumar
3 Replies

6. Shell Programming and Scripting

Check if a variable ends in a particular number

Hi guys, I am working on a server where there are many users. The user names end in a 1 or a 2. I want to write a bash script that will say which users are in which group and was wondering if I could get some help. The only part I am unsure of is how to check if it ends in the number. Here's... (2 Replies)
Discussion started by: wua05
2 Replies

7. UNIX for Dummies Questions & Answers

deletion of all lines ends with :

I have below file say temp1 BSCAJM1:HWJA10C BSCAJM1: BSCALW1: BSCALW1:GVND01B BSCALW1: BSCALW1: BSCBKNR:IJNMKTA BSCBKNR: BSCJOD1: BSCJOD1:JOD121B i want to delete all the lines ending with : and have below output BSCAJM1:HWJA10C BSCALW1:GVND01B BSCBKNR:IJNMKTA... (8 Replies)
Discussion started by: lalchand
8 Replies

8. Shell Programming and Scripting

i want to know entered string ends with .jar

Hi all, I want to know whelther string entered ends with .jar. Can any one help please.. Thank U Naree (3 Replies)
Discussion started by: naree
3 Replies

9. UNIX for Dummies Questions & Answers

Email ends with Junk Characters

I have written the following code ...to include the Subject, Message Body and Attachment with sendmail. When I send mail from my Unix account to diffrent mail servers like Yahoo , Hotmail etc..I recv the Message Body but there is no newline character at the end of each line.... Also I recv the... (5 Replies)
Discussion started by: Amruta Pitkar
5 Replies

10. Shell Programming and Scripting

file transfer ends

how can I tell when a ftp/sftp file has completed - I'm having trouble by picking up a file that is still being transferred to - is there a better way to transfer files across systems??? (4 Replies)
Discussion started by: jph
4 Replies
Login or Register to Ask a Question