Skip to main content
Until loop 


The until loop is very similar to the while loop, except that the loop executes until the TEST-COMMAND executes successfully. As long as this command fails, the loop continues. The syntax is the same as for the while loop:
until TEST-COMMAND; do CONSEQUENT-COMMANDS; done
The return status is the exit status of the last command executed in the CONSEQUENT-COMMANDS list, or zero if none was executed.TEST-COMMAND can, again, be any command that can exit with a success or failure status, and CONSEQUENT-COMMANDS can be any UNIX command, script or shell construct.


Example :--            Write a shell script to display first ten positive numbers using until loop.         
                          
Program

num=1
until [ $num –gt 10 ]; do
echo num
num=`expr $num + 1 `
done

OUTPUT:

1
2
3
4
5
6
7
8
9
10

Comments

Popular posts from this blog

    METACHAR ACTER   UNIX  shell  अनेक मेटाचारेक्टर प्रोवाइड करता है जो किसी भी शैल स्कफ्रिप्त में उनका उसे करते टाइम विषेस माइनिंग रखते और जब तक काशी सोवळे नहीं हो जाते तब काट किसी वर्ड का एंडिंग का कारन बनते है।                                                     ex:--     एक directory में फिलो को लिस्टिंग करते टाइम एक सिंगल चैरेक्टर में रखा जाता है और * एक से अधिक वर्ड को मैचेस करता है यह शैल के अधिकांश पत्रों को लिस्ट दी गयी है जिन्हे metacharacter बोला  जाता है.   * ? [ ] " ' \    /    $ : ; ( ) | ^ < >  \.   नई लाइन स्पेस तब   #!/bin/sh  echo hello; word  #!/bin/sh  echo "I have \$1200" 1. <  single quotes : all special charecters between these quotes lose their special.  ex. --...