Sponsored Content
Top Forums Shell Programming and Scripting Jump to next element in a loop Post 302646345 by Scrutinizer on Friday 25th of May 2012 03:00:39 AM
Old 05-25-2012
Or use "continue":
Code:
for i in 1 2 3 4 5 6
do
  if [ $i -eq 2 ]
  then
    continue #jump to element 3
  else
    echo $i
  fi
done

This User Gave Thanks to Scrutinizer For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Jump to a specific place in a file?

If I cat a file And want to go to the first instance of a particular value - what command would I use? And then from that point where I jumped to search for another value - but only search from that point forward not before the file? Thanks~ (2 Replies)
Discussion started by: llsmr777
2 Replies

2. AIX

jump in a .KSH batch

hi everyone, i need to know if is that possible insert in a batch KSH a "GO TO" sentence to jump at the top or at the end of the job. e.g. top: step1 step2 go to top: thanks in advance (4 Replies)
Discussion started by: enge
4 Replies

3. Shell Programming and Scripting

[bash] jump from one txt file to another

Hi all, I need to create a bash script that reads a txt file on a remote (Windows 2003) server, gets the IP-addresses out of it and then fetches the folders to copy out of another txt file. (all files are auto-generated) The IP addresses that don't have a folder_list file should be ignored. At... (31 Replies)
Discussion started by: laurens
31 Replies

4. Shell Programming and Scripting

HELP unsetting array element in loop

I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that... (2 Replies)
Discussion started by: msf5042
2 Replies

5. Shell Programming and Scripting

how to jump a shell !!

Hi, can someone point out a solution to my problem below. Within a shell script TEST.ksh I have to run two commands CmdA & CmdB one after the other as below. ------------- TEST.ksh #!/usr/bin/ksh A B ------------- I am running this script from KSH with PID 12345 as below. ... (5 Replies)
Discussion started by: krishnaux
5 Replies

6. Solaris

Jump Start vs Flash Archive

Hi I'm trying to understand the difference between installation methods of Solaris 10, Jump Start vs Flash Archive ? thx for help. (6 Replies)
Discussion started by: presul
6 Replies

7. Shell Programming and Scripting

Find if XML element has a matching required element

I want to check if every <Part> element has corresponding <Description> in this sample XML. ....<Lot Of XML> <Inv lineNumber="2"> <Item> ... (4 Replies)
Discussion started by: kchinnam
4 Replies

8. Shell Programming and Scripting

jump to a section in output

HI I have the following output from an autosys command . Now I would like to investigate further .i.e Start Dependent Job Name Status ... (3 Replies)
Discussion started by: ptappeta
3 Replies

9. Shell Programming and Scripting

Print the row element till the next row element appear in a column

Hi all I have file with columns F3 pathway CPS F2 H2 H4 H5 H6 no pathway CMP H7 H8 H9 H10 My expected output is F3 pathway CPS F2 pathway CPS (10 Replies)
Discussion started by: Priyanka Chopra
10 Replies
foreach(n)						       Tcl Built-In Commands							foreach(n)

__________________________________________________________________________________________________________________________________________________

NAME
foreach - Iterate over all elements in one or more lists SYNOPSIS
foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body _________________________________________________________________ DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been used to extract the element, then calls the Tcl interpreter to execute body. In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough elements for each of its loop variables in each iteration, empty values are used for the missing elements. The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string. EXAMPLES
The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO
for(n), while(n), break(n), continue(n) KEYWORDS
foreach, iteration, list, looping Tcl foreach(n)
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy