Sponsored Content
Top Forums Shell Programming and Scripting problem with for loop and a variable with spaces...Hi Post 302414918 by radoulov on Wednesday 21st of April 2010 09:58:57 AM
Old 04-21-2010
Quote:
Originally Posted by chebarbudo
[...]
Thanks radoulov for helping but your commands does not work with the sentence in a variable.
Actually I was suggesting to use an array variable instead of scalar variable ...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies

2. Shell Programming and Scripting

Problem with variable expension using for loop.

Hi, I have a problem with expending variables when used in a for loop: #!/bin/ksh VAR1=aaa VAR2=bbb VAR3=ccc for ITEM in VAR1 VAR2 VAR3 do echo "${ITEM}" done This gives: VAR1 VAR2 VAR3 (2 Replies)
Discussion started by: ejdv
2 Replies

3. Shell Programming and Scripting

Variable problem in for loop with if statement

Hi, Again a little problem. Do not understand good why an empty string is not detected. Here is the program: #!/bin/ksh APR=`date | grep Apr | awk '{print $2$3}'` MAY=`date | grep May | awk '{print $2$3}'` JUN=`date | grep Jun | awk '{print $2$3}'` echo "Variable Apr has value:... (6 Replies)
Discussion started by: ejdv
6 Replies

4. UNIX for Dummies Questions & Answers

For loop using find with file name spaces

Hello All, This question is actually for the service console of VMware ESX 3.5 but is relevant to this forum I think. I have been advised to use the following commands: for i in `find /vmfs/volumes/Test_VMFS/ -name "*.vmx"` do echo "$i" #sed -i 's/scsi1:0.present =... (3 Replies)
Discussion started by: mronsman
3 Replies

5. Shell Programming and Scripting

for loop ( string having spaces )

Dear All, i facing problem to use string having spaces in for loop.. file used for FOR LOOP command.txt rpm -t -v ttm -D -r RJLL -h YELP rpm -t -v ttm -D -r RJLL -h ERRT rpm -t -v ttm -D -r RJLL -h TYYE rpm -t -v ttm -D -r RJLL -h POOL CODE using for execute above command... (3 Replies)
Discussion started by: arvindng
3 Replies

6. Shell Programming and Scripting

Bourne Shell - Problem with while loop variable scope.

Hello I am having issues with a script I'm working on developing on a Solaris machine. The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today. Here is my while loop: last $user | grep -v 'sshd'... (7 Replies)
Discussion started by: DaveRich
7 Replies

7. Shell Programming and Scripting

Loop with Find—damn spaces!

Hi Guys, I'm trying to find all files with a particular extension and then loop some actions. The problem is that if the files have spaces in their names I get end up being each word as a separate result rather than the entire file. ext=".txt" out=".rtf" for i in $( find "$1" -name "*$ext" );... (9 Replies)
Discussion started by: imonkey
9 Replies

8. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

9. Shell Programming and Scripting

String variable concatenation through loop problem

Hi Team!! Please can anyone tell me why the following line does not work properly? str3+=$str2 it seems that str3 variable does not keep its value in order to be concatenated in the next iteration! Thus when i print the result of the line above it returns the str2 value What i want to do is to... (8 Replies)
Discussion started by: paladinaeon
8 Replies

10. UNIX for Dummies Questions & Answers

Awk: problem for loop through variable

Hi, input: AAA|1 my script (the function is just an example): gawk 'BEGIN{FS=OFS="|"} function repeat(str, n, rep, i){ for(i=1; i<=n; i++) rep=rep str return rep } { variable_1=repeat($1,$2) variable_2=repeat($1,$2+1) variable_3=repeat($1,$2+3) ... (5 Replies)
Discussion started by: beca123456
5 Replies
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)
All times are GMT -4. The time now is 12:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy