Sponsored Content
Top Forums Shell Programming and Scripting While loop with limit counter Post 302990692 by Don Cragun on Monday 30th of January 2017 08:25:08 PM
Old 01-30-2017
When I try your script with || changed to &&:
Code:
#!/bin/ksh

c=0
while [[ ! -f /tmp/unex && $c -lt 10 ]]; do 
    echo /tmp/unex NOT found, iter : $c;
    ((c = $c + 1));
    sleep 2; 
done

(note that ksh is in /bin instead of /usr/bin on my system) and the file /tmp/unex does not exist; I get the output:
Code:
/tmp/unex NOT found, iter : 0
/tmp/unex NOT found, iter : 1
/tmp/unex NOT found, iter : 2
/tmp/unex NOT found, iter : 3
/tmp/unex NOT found, iter : 4
/tmp/unex NOT found, iter : 5
/tmp/unex NOT found, iter : 6
/tmp/unex NOT found, iter : 7
/tmp/unex NOT found, iter : 8
/tmp/unex NOT found, iter : 9

and it then quits. Isn't that what you want?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop counter variable display

Hello everyone, how can I send output to the screen from a running script or tcl, in such a way that if a loop is executing I will see the rolling counter on my screen as the records are processed in the loop. I do not want the screen to scroll, though. In other words can a var's value be painted... (2 Replies)
Discussion started by: lifespan
2 Replies

2. Shell Programming and Scripting

adding counter to a variable while moving in a loop

The scenario is like this : I need to read records from a file one by one and increment counter1, if a certain field matches with a number say "40"..the script should increment the counter2 and also extract a corresponding field from the same line and adding them one by one and redirecting the the... (5 Replies)
Discussion started by: mady135
5 Replies

3. Shell Programming and Scripting

S# in a for loop - concatenate $(loop counter)

Hi, hope I am posting in the right section. My problem is that I have 2 or more arguments passed and I want to check if the arguments passed exists or not. The first argument should not exist and the remaining others should exist. example: ./shells.sh argument1 argument2 argument3 ... (5 Replies)
Discussion started by: fight4love
5 Replies

4. Shell Programming and Scripting

loop with a counter on a constant in bash

Hello Everyone, I'm in need of assistance on creating a script with a counter on a certain string. Basically this script opens a log file and displays certain log data. There are two key words in the log. START and FINISH. In between the START and FINISH is a variable ACTNUMBER. It will... (1 Reply)
Discussion started by: rxc23816
1 Replies

5. Shell Programming and Scripting

File merging based on different counter loop

hello, File 1 main Group sub group MIT VAR_1D_DATA_TYPE 23-03-2012 MIT VAR_1D_DATA_TYPE 22-03-2012 MIT VAR_10D_DATA_TYPE 23-03-2012 MIT VAR_10D_DATA_TYPE 22-03-2012 MIT ... (0 Replies)
Discussion started by: manas_ranjan
0 Replies

6. Shell Programming and Scripting

How to use counter to run the script to limit number?

I want to run my shell script to the limit number.Suppose I know in advance that MAX=5 then I want that my script run 5 times only.Something like below$ vi testingMAX=5COMMAND="ssh -l stpuser VHLDVWSAD001 /projects/st/utils/deploy/deployall.sh >/dev/null 2>&1 &" ; sleep 20;count=0while... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

7. Shell Programming and Scripting

How to implement the counter in loop?

Hi, I am working on a script where I need to add one functionality i.e. to could the number of tar files at particular location...but the script is working in below way. 1) create sandbox 2) Drop old member function 3) addmember function 4) Apply checkpoint lable 5) Resync operation(This... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

8. Shell Programming and Scripting

Loop usage with counter

Hi friends, I just want to try some thing with shell using loop and counter I have 30 Directory, in each directory number of files say 5, 10, 20 etc... directory_1 directory_2 directory_n what I want to do is read files from directory_1 say 5 files if my counter is like this m=2000 ... (6 Replies)
Discussion started by: Akshay Hegde
6 Replies

9. Shell Programming and Scripting

Avoid multiple emails being sent - Counter, Loop?

Hello, I have currently coded a bash script below in which it does the following: # Archives compressed file from another location. Basically it moves *.gz files to another location. The script also sends an email whenever a new compressed file is placed. This is the issue that i... (5 Replies)
Discussion started by: Wizard_1979
5 Replies

10. Shell Programming and Scripting

Loop counter resets by itself

Hi! Can anyone explain this? The counter CDR_count should go on forever, but it suddenly resets at every step of the FOR loop (I know this because $_file has exactly 378 records). However, the counter reset is OUTSIDE the FOR loop. What's going on?? #!/bin/bash if || ; then echo ... (8 Replies)
Discussion started by: Flavius
8 Replies
PROP_OBJECT(3)						   BSD Library Functions Manual 					    PROP_OBJECT(3)

NAME
prop_object, prop_object_retain, prop_object_release, prop_object_type, prop_object_equals, prop_object_iterator_next, prop_object_iterator_reset, prop_object_iterator_release -- general property container object functions LIBRARY
Property Container Object Library (libprop, -lprop) SYNOPSIS
#include <prop/proplib.h> void prop_object_retain(prop_object_t obj); void prop_object_release(prop_object_t obj); prop_type_t prop_object_type(prop_object_t obj); bool prop_object_equals(prop_object_t obj1, prop_object_t obj2); prop_object_t prop_object_iterator_next(prop_object_iterator_t iter); void prop_object_iterator_reset(prop_object_iterator_t iter); void prop_object_iterator_release(prop_object_iterator_t iter); DESCRIPTION
The prop_object family of functions operate on all property container object types. prop_object_retain(prop_object_t obj) Increment the reference count on an object. prop_object_release(prop_object_t obj) Decrement the reference count on an object. If the last reference is dropped, the object is freed. prop_object_type(prop_object_t obj) Determine the type of the object. Objects are one of the following types: PROP_TYPE_BOOL Boolean value (prop_bool_t) PROP_TYPE_NUMBER Number (prop_number_t) PROP_TYPE_STRING String (prop_string_t) PROP_TYPE_DATA Opaque data (prop_data_t) PROP_TYPE_ARRAY Array (prop_array_t) PROP_TYPE_DICTIONARY Dictionary (prop_dictionary_t) PROP_TYPE_DICT_KEYSYM Dictionary key symbol (prop_dictionary_keysym_t) If obj is NULL, then PROP_TYPE_UNKNOWN is returned. prop_object_equals(prop_object_t obj1, prop_object_t obj2) Returns true if the two objects are of the same type and are equivalent. prop_object_iterator_next(prop_object_iterator_t iter) Return the next object in the collection (array or dictionary) being iterated by the iterator iter. If there are no more objects in the collection, NULL is returned. prop_object_iterator_reset(prop_object_iterator_t iter) Reset the iterator to the first object in the collection being iterated by the iterator iter. prop_object_iterator_release(prop_object_iterator_t iter) Release the iterator iter. SEE ALSO
prop_array(3), prop_bool(3), prop_data(3), prop_dictionary(3), prop_number(3), prop_string(3), proplib(3) HISTORY
The proplib property container object library first appeared in NetBSD 4.0. BSD
August 21, 2006 BSD
All times are GMT -4. The time now is 03:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy