Sponsored Content
Top Forums Shell Programming and Scripting BASH loop inside a loop question Post 302453410 by Klashxx on Wednesday 15th of September 2010 07:14:14 AM
Old 09-15-2010
Try this:
Code:
#!/usr/bin/ksh

RESULT=`/usr/local/bin/myutility`
COUNT=0

while [ "${RESULT}." = "0000." ]
do
    (( COUNT += 1 ))
   
    if (( COUNT <= 20 ))
    then 
        RESULT=`/usr/local/bin/myutility`
    else
       break
    fi
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

while loop inside while loop

Dear All, i have a awk script where i'm using while loop inside while loop here is the code: awk -v DATE="$CURRDATE" -v -F'@' 'BEGIN { while(( getline < "Merge_Calldet.txt" )) { ARR=$5 LINE=$0 while(( getline < "Merge_Accessnum.txt" )) { TESTSIMENTRY=$1 FILEDATE=$15 ... (0 Replies)
Discussion started by: panknil
0 Replies

2. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

3. Shell Programming and Scripting

Is it possible to have a for loop inside another for loop?

Is it possible to have a for loop nested inside another for loop? I am trying to run a script against specific files inside a child directory but I can't seem to find a solution that is clean and affect to do it. Here is what I am trying do. I have 2 gzip files in each of the Target Directories... (4 Replies)
Discussion started by: scottzx7rr
4 Replies

4. Shell Programming and Scripting

For Loop inside For loop

I am new to unix and trying to make a script for writing all my command into another file and use that file to run all commands I am trying to use for loop with echo command to generate a command based script for writing the file with all the command sequentially w.r.t for loop. I want... (6 Replies)
Discussion started by: nnani
6 Replies

5. UNIX for Dummies Questions & Answers

while loop inside a for loop

Hi, I am a newbie and would like to create a shell script that will move one file at a time from one path to another path in the same server. However, the next file should wait until the first file gets deleted by an application. I tried creating the script but right after the first file has... (1 Reply)
Discussion started by: rgomons
1 Replies

6. Shell Programming and Scripting

If inside If loop

Hi All, Below is the very simple code snippet but it si giving me syntax error #!/bin/bash #To ensure If JMS directory exists or not ServerName=$(hostname) #To ensure If JMS directory exists or not echo $ServerName if ; then echo "Inside First If" if ; then echo 'JMS... (4 Replies)
Discussion started by: sharsour
4 Replies

7. Shell Programming and Scripting

Bash script - loop question

Hi Folks, I have a loop that goes through an array and the output is funky. sample: array=( 19.239.211.30 ) for i in "${array}" do echo $i iperf -c $i -P 10 -x CSV -f b -t 50 | awk 'END{print '$i',$6}' >> $file done Output: 19.239.211.30 19.2390.2110.3 8746886 seems that when... (2 Replies)
Discussion started by: nitrohuffer2001
2 Replies

8. Shell Programming and Scripting

Bash Question: HowTo Exit Script with User Input While Process is Running Mid-Loop?

Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
Discussion started by: hilltop_yodeler
9 Replies

9. UNIX for Dummies Questions & Answers

Write a while loop inside for loop?

I'm taking a unix class and need to countdown to 0 from whatever number the user inputs. I know how to do this with a while or until loop but using the for loop is throwing me off.... I know I can use an if-then statement in my for loop but can I include a while loop in my for loop? (3 Replies)
Discussion started by: xxhieixx
3 Replies

10. Shell Programming and Scripting

Bash - How to do a "read -p" inside a while loop?

Hi there guys! I was trying to do: while read line; do if ; then read -p "Press Enter to continue..." cont=0 fi echo $line let cont++ done < file.txt However, I have read that the read -p would not work in a while loop... I was wondering if there is any other way to... (2 Replies)
Discussion started by: rplae
2 Replies
SG_SYNC(8)							     SG3_UTILS								SG_SYNC(8)

NAME
sg_sync - send the scsi command synchronize cache SYNOPSIS
sg_sync [--count=COUNT] [--group=GROUP] [--help] [--immed] [--lba=LBA] [--sync-nv] [--verbose] [--version] DEVICE DESCRIPTION
Send SYNCHRONIZE CACHE (10) command to DEVICE. This command is defined for SCSI block devices (see SBC-2). If successful this command makes sure that any blocks whose latest versions are held in (volatile) cache are written to (also termed as "synchronized with") the medium. If the --sync-nv option is given and the device has a non-volatile cache then any blocks whose latest versions are held in volatile cache are written to non-volatile cache. If the LBA and COUNT arguments are both zero (their defaults) then all blocks in the cache are synchronized. If LBA is greater than zero while COUNT is zero then blocks in the cache whose addresses are from and including LBA to the highest lba on the device are synchronized. If both LBA and COUNT are non zero then blocks in the cache whose addresses lie in the range LBA to LBA+COUNT-1 inclusive are synchronized with the medium. OPTIONS
Arguments to long options are mandatory for short options as well. -c, --count=COUNT where COUNT is the number of blocks to synchronize from and including LBA. Default value is 0. When 0 then all blocks in the (volatile) cache from and including LBA argument to the highest block address are synchronized. -g, --group=GROUP where GROUP is the group number which can be between 0 and 31 inclusive. The default value is 0 . Group numbers are used to segre- gate data collected within the device. This is a new feature in SBC-2 and can probably be ignored for the time being. -h, --help output the usage message then exit. -i, --immed sets the IMMED bit in the SYNCHRONIZE CACHE command. This instructs the device, if the format of the command is acceptable, to return a GOOD status immediately rather than wait for the blocks in the (volatile) cache to be synchronized with (i.e. written to) the medium (or the non-volatile cache). -l, --lba=LBA where LBA is the lowest logical block address in the (volatile) cache to synchronize to the medium (or the non-volatile cache). Default value is 0 . -s, --sync-nv synchronize the (volatile) cache with the non-volatile cache. Without this option (or if there is no non-volatile cache in the device) the synchronization is with the medium. -v, --verbose increase the level of verbosity, (i.e. debug output). -V, --version print the version string and then exit. NOTES
The COUNT, GROUP and LBA arguments may be followed by one of these multiplicative suffixes: c C *1; w W *2; b B *512; k K KiB *1,024; KB *1,000; m M MiB *1,048,576; MB *1,000,000 . This pattern continues for "G", "T" and "P". Also a suffix of the form "x<n>" multiplies the leading number by <n>. The "T" and "P" suffixes can only be used for COUNT and LBA. Alternatively numerical values can be given in hexadecimal preceded by either "0x" or "0X" (or with a trailing "h" or "H"). When hex num- bers are given, multipliers cannot be used. EXIT STATUS
The exit status of sg_sync is 0 when it is successful. Otherwise see the sg3_utils(8) man page. AUTHORS
Written by Douglas Gilbert. REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2004-2006 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_start(sg3_utils) sg3_utils-1.22 December 2006 SG_SYNC(8)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy