Sponsored Content
Full Discussion: Execute while loop
Top Forums UNIX for Advanced & Expert Users Execute while loop Post 302278413 by angheloko on Tuesday 20th of January 2009 07:13:36 AM
Old 01-20-2009
Here's the syntax of while loop:

Code:
while command_t
do
         command
         command
         ...
done

Where command_t is executed and its exit status tested. If it's zero, the commands enclosed between the do and done are executed. Then command_t is executed again and its exit status tested. If it's zero, the commands enclosed between the do and done are once again executed. This process continues until command_t returns a nonzero exit status. At that point, execution of the loop is terminated. Execution then proceeds with the command that follows the done.

Why not substitute 1 with true and drop the parenthesis, braces, and brackets Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute commands parallel in a for loop ?

Hi, please can someone point me in the right direction with a shell scripting problem. I want to execute a command in a for loop and the command should be started not one-by-one meaning the for loop is waiting for the exit code , it should be started in parallel. I have a plain text file... (3 Replies)
Discussion started by: networkfre@k
3 Replies

2. Shell Programming and Scripting

loop does not execute in bash script?

I have a very basic bash shell script, which has many "while... done; for .... done" loop clauses, like the following ~~ #!/bin/bash while blablalba; do .... done < /tmp/file for line in `cat blablabla`; do grep $line /tmp/raw ; done > /tmp/1; while blablalba2; do .... done <... (2 Replies)
Discussion started by: fedora
2 Replies

3. UNIX for Dummies Questions & Answers

how to execute a while loop for 20 minutes?

I want to execute a while loop (or any other loop) for 20 minutes. I have extracted the minutes and seconds from the current system date by using the command y = `date +%M%S` How to proceed ?? (6 Replies)
Discussion started by: subhotech
6 Replies

4. Shell Programming and Scripting

Execute Loop in Telnet

hi Everyone , have a nice day #!/bin/sh ( sleep 1 echo "LOGIN:username:password;" sleep 1 while IFS= read -r line do #echo $line GET:VOUCHERDETAIL:VoucherSerialNumber,$line; >> /home/status_log done < /home/status.txt sleep 1 echo "LOGOUT;") | telnet 127.0.0.1 7021 , it... (2 Replies)
Discussion started by: Dastard
2 Replies

5. UNIX for Dummies Questions & Answers

For Loop to execute a command on a series of files

Hello, I have a set of input data that I split into batches using the following command: split -l 4000000 MyInput.in Split_a Once I get the split files, I run a certain command on the split files that spews an output. So far I have been doing it without a for loop. How can I translate the... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies

6. UNIX for Dummies Questions & Answers

unable to execute while loop

Hi everyone. I wanted to print numbers from 1 to 5 in reverse order. For this I used the following code: #!/bin/bash x=5 while do echo $x x=`expr $x - 1` echo "" done echo "" Well but on compiling the above code, it gives the following error. ... (3 Replies)
Discussion started by: grc
3 Replies

7. Shell Programming and Scripting

How to execute a no of SELECT COUNT(*) statements using a loop

HI Unix Gurus, I have a number of SELECT count(*) statements in an input file and I want to execute it using a shell script but one by one using loop in script.... How can I do this..... (7 Replies)
Discussion started by: ustechie
7 Replies

8. Shell Programming and Scripting

Execute command with loop

I have a below command ALTER TABLE `abc` ADD PARTITION ( PARTITION 20130613 VALUES less than (DAY('13'))); Below is requirement It runs in Loop as DAY start with 13 and end with 100 along with this of counter "20130613" also increases per command as the next command should be ... (8 Replies)
Discussion started by: kaushik02018
8 Replies

9. Shell Programming and Scripting

How to execute a command inside a while loop?

How do we execute a command inside a while loop? (7 Replies)
Discussion started by: Little
7 Replies

10. Shell Programming and Scripting

Exit while loop on execute script

Hi, I have first script which on IR remote command event execute the second script. If the second script is executed, it display echo "timeout expired" after 10s. This works as expected. But I also want to reset timer (increase time) in case if the second script is executed again within 10s. ... (8 Replies)
Discussion started by: armatron
8 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 07:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy