09-12-2011
Test that the value held in variable "i" (typically used for an index variable) is less than 3. Note that variable i is incremented at the end of the loop, increasing its value by 1. So, it loops 3 times and is used as the index of the array called "log", thus displaying its contents.
You could use (( $i < 3 )) which may make more sense?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a script which tries to read input from a user for every value read from a file. The input file is
#> more testfile
TEST1 | D200 | 12345601 | | ABC company | m
TEST2 | D201 | 12345602 | | ABC company | m
The script test.sh is as follows
while read line
do
read test?"Enter a... (5 Replies)
Discussion started by: jerardfjay
5 Replies
2. Shell Programming and Scripting
currentSid=${TWO_TASK:-$ORACLE_SID}
echo $currentSid
this script returns value of ORACLE_SID but what i am not getting is
what is ":-" doing ?? (1 Reply)
Discussion started by: zedex
1 Replies
3. Solaris
if
then
ROLLBACK=1 ;
elif
then
echo "Nothing to install!" ;
echo "Exiting." ;
exit 0;
Plz explaing what is the ${1:-0} in if loop?:) (3 Replies)
Discussion started by: ysrikanth
3 Replies
4. Shell Programming and Scripting
#! /bin/sed -nf
# Remove C and C++ comments, by Brian Hiles (brian_hiles@rocketmail.com)
# Sped up (and bugfixed to some extent) by Paolo Bonzini (bonzini@gnu.org)
# Works its way through the line, copying to hold space the text up to the
# first special character (/, ", '). The original... (1 Reply)
Discussion started by: Priyaranjan
1 Replies
5. Shell Programming and Scripting
Guys,
I am new in awk , I face problem while i try to use for loop in awk,
I am using ksh, i am trying to set a for loop which runs as man times as the records in a file , the for loop like for(a=1;a<=5;a++) is working in my awk script but the one i need is not working :wall:
for example
... (8 Replies)
Discussion started by: djahmed
8 Replies
6. Shell Programming and Scripting
Hello Everyone,
I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following:
* I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Discussion started by: jimmy75_13
13 Replies
7. Shell Programming and Scripting
Hi,
I'm trying to write a for loop to run through a list of servers and for each server copy a file to a backup file. But I can't seem to get it to run through my server list. It work for individual servers, please see below.
#!/bin/ksh
SSH_USERID=khcuser
webservers="server1 server2"
... (2 Replies)
Discussion started by: elmesy
2 Replies
8. Shell Programming and Scripting
Hi i am new to shell script can any one please explain me the code below which is written for execution of python scripts which are located in same folder.
please explain the code line by line
ls *.py > xx
while
do
read myline || break
python $myline
done<xx
Thanks
Mukthyar.... (1 Reply)
Discussion started by: mukthar1255
1 Replies
9. Shell Programming and Scripting
Please explain why this works. Am unable to find another definition for the '%', which would explain this behaviour:
spaceLeft=`df -h /myPartition | tail -1`
# output looks like: /dev/sda5 10G 1.2G 12G 29% /
set -- $space
#this deletes the trailing '%' sign, which is... (6 Replies)
Discussion started by: frododot
6 Replies
10. Shell Programming and Scripting
Hi, I am new to UNIX. I am working on a script where it takes the input and produces a desired output and it works fine for one instance.
Input(One Instance):
CREATE TABLE TAB1
(
COL1,
COL2
);
CREATE UNIQUE INDEX XPKTAB1
(
COL1
)TAB1;
Output:
CREATE TABLE TAB1
(
COL1,
COL2... (8 Replies)
Discussion started by: varun2327
8 Replies
LEARN ABOUT OSX
tcl_upvar2
Tcl_UpVar(3) Tcl Library Procedures Tcl_UpVar(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_UpVar, Tcl_UpVar2 - link one variable to another
SYNOPSIS
#include <tcl.h>
int
Tcl_UpVar(interp, frameName, sourceName, destName, flags)
int
Tcl_UpVar2(interp, frameName, name1, name2, destName, flags)
ARGUMENTS
Tcl_Interp *interp (in) Interpreter containing variables; also used for error reporting.
const char *frameName (in) Identifies the stack frame containing source variable. May have any of the forms accepted by the
upvar command, such as #0 or 1.
const char *sourceName (in) Name of source variable, in the frame given by frameName. May refer to a scalar variable or to an
array variable with a parenthesized index.
const char *destName (in) Name of destination variable, which is to be linked to source variable so that references to destName
refer to the other variable. Must not currently exist except as an upvar-ed variable.
int flags (in) One of TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY or 0; if non-zero, then destName is a global or namespace
variable; otherwise it is local to the current procedure (or current namespace if no procedure is
active).
const char *name1 (in) First part of source variable's name (scalar name, or name of array without array index).
const char *name2 (in) If source variable is an element of an array, gives the index of the element. For scalar source vari-
ables, is NULL.
_________________________________________________________________
DESCRIPTION
Tcl_UpVar and Tcl_UpVar2 provide the same functionality as the upvar command: they make a link from a source variable to a destination
variable, so that references to the destination are passed transparently through to the source. The name of the source variable may be
specified either as a single string such as xyx or a(24) (by calling Tcl_UpVar) or in two parts where the array name has been separated
from the element name (by calling Tcl_UpVar2). The destination variable name is specified in a single string; it may not be an array ele-
ment.
Both procedures return either TCL_OK or TCL_ERROR, and they leave an error message in the interpreter's result if an error occurs.
As with the upvar command, the source variable need not exist; if it does exist, unsetting it later does not destroy the link. The desti-
nation variable may exist at the time of the call, but if so it must exist as a linked variable.
KEYWORDS
linked variable, upvar, variable
Tcl 7.4 Tcl_UpVar(3)