10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
How do we execute a command inside a while loop? (7 Replies)
Discussion started by: Little
7 Replies
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. UNIX for Dummies Questions & Answers
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
6. UNIX for Dummies Questions & Answers
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
7. Shell Programming and Scripting
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
8. UNIX for Dummies Questions & Answers
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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
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)