incrementing the variable name along with the data?
Hello folks.
I am trying to increment my variable names to match a counter that is to be used later on...
Basically, i have a for loop that lists directories (for example TEST_OS DVP_OS PROD_OS ) but this loop is not static, it may contain 3 directory once and the next run 5 directories.
I then, want to assign "selection1" to TEST_OS, "selection2" to DVP_OS and "selection3" to PRD_OS. Again, those are not static...
Here is the code i have for now, but the "combining" of variables is not working... (selection$counter=$i) What i want, is that the variable selection1=TEST_OS and so forth...
Could you please elaborate more: which OS and shell are you using?
Could you post an example of the directory structure and what should be the output (variable content) based on that structure?
The script in Post #1 is not sound in this context.
Please post a specification for what you are trying to achieve - including sample input and sample output - complete with a description of the process.
It is impossible to determine the process based on faulty code and a garbled process specification.
Further to radlouv, please do post what Operating System and version you have and what Shell you prefer.
Please take the time to describe the process such that an 11-year-old would understand.
Thanks for this code...Can i "echo" this variable to see its content, just to debug for now...Since this is using the eval, is it echoed differently? a simple echo won't do. I get no errors, but no idea what is in the "selection" variable.
Thanks.
---------- Post updated at 02:05 PM ---------- Previous update was at 02:00 PM ----------
Thanks radoulov. Let's see if i can get this to work...
This is part of a larger script where I need to pass only 1 line of a file to the script, based on a variable and not a direct reference.
As part of a for loop :
# for((line=0;line<50;line++)); do
# awk ‘NR==$line' PhraseList.txt; done
... (5 Replies)
Hi
I have the below set of lines , i need to duplicate these lines 1000 times, also eevrytime when it is incremented , it should increment the one in Blue color.
130400030000010000200001
130400030000010000200002
140050030000010000200005A
eg:
130400030000010000200001... (5 Replies)
Hi All,
I was wondering how I can convert each line in an input file where fields are separated by variable width spaces into a CSV file. Below is the scenario what I am looking for.
My Input data in inputfile.txt
19 15657 15685 Sr2dReader 107.88 105.51... (4 Replies)
Hi,
want to increment a variable in a for loop like this:
for (( c=$total-1; c>=0; c-- ))
do
if ;
then
maximo=$valores
fi
done
But it gives the error:
No such file or directory
How can i do this only incrementing the c variable?
Thanks (8 Replies)
Hi,
I am using BASH. I have encountered a situation where the following is necessary (but I am not sure how to do it):
#Define multiple arrays, whose names only differ by a number:
ARRAY_1=(1 2 3)
ARRAY_2=(4 5 6)
ARRAY_3=(7 8 9)
#Define ARRAY_AMOUNT, the number of arrays. In this case... (1 Reply)
When I did,
echo $SHELL in cmd prompt of putty,
its displaying /bin/sh
And in my shell script.,
I hav started with.,
#!/bin/sh
and
i=1;
while ;
do
.
.
.
i=$; (9 Replies)
1. The problem statement, all variables and given/known data:
Variable is resetting to 0 after incrementing in while loop
My bit of scripting displays the current users logged in the machine.
Then it reads in a specific username and displays the processes for that user.
The portion that I... (3 Replies)
Hi All,
Iam trying to increment a variable
Following is the code
#!/usr/bin/ksh
i=1;
i='expr $i+1';
echo $i;
Output:
expr $i+1
not able to understand why its happening in that way
i was expecting result as 2... if the above method is worng .. can you help how i can get... (3 Replies)
Hi all,
I have a variable with date as 20080831 . Now I want to increment it as 20080901 and so on.Is there any command for this. Please help me.
thanks
rameez (1 Reply)
I have 3 columns in an excel sheet.
c1 c2 c3
EIP_ACCOUNT SMALL_TS_01 select A.* from acc;
All the above 3 col shoud be passed a variable in the unix code.
1.How to read an excel file
2.How to pass these data as variable to the unic script (1 Reply)