Here is the thing; I have a trouble in this simple situation, I'm trying to write an array with all the arguments of a command. I mean, if I have:
I need to take an array like this:
myarray=(aa bb cc dd)
So I use a simple for loop like this:
I don't know how to construct the expression to take the i variable with its growing values (1, 2, 3, ... n) and become it in the variable who represents the argument ($1, $2, $3, ... $n) and save the arguments values into the array (aa, bb, cc, ... whatever).
If I do
of course I'll have myarray=(1 2 3 4), not the needed array myarray=(aa bb cc dd)
Here $i represents the arguments which is taken one by one and assigned to myarray in an index of argument possition.
You don't need to loop the arguments to create array, check this out,
For your information,
Just assume, if you assign the array like below,
You output array should be myarray=('aa' 'bb') and these 0,1 represent the indexes which represents the position of array element.
My string variable which gets the output from the result of a database query has values as below:
line="2019-09-11 15:17:55 CR1234 anonymous Deployed DR_only Back_APP"
I wish to construct an array (my_array) which should have entries as below.
Note:
1. The first... (6 Replies)
I am trying to check whether particular host and port are responding or not. I am using below script to check. but node_port array that i am using in loop is getting replaced with previous iteration value. Script and output is given.
Please help me to understanding why node_port values are... (5 Replies)
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)
Hi,
There are total 100 files in the backup directory with the name format as below:
prod_bkp_140611_13_30_05.txt
prod_bkp_140611_14_30_05.txt
prod_bkp_140611_15_30_05.txt
prod_bkp_140611_16_30_05.txt
How to use array variables (in perl) to get list of names of the above files ? (13 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Sorry for such a dreadful title, but I'm not sure how to be more descriptive. I'm hoping some of the more gurutastic out there can take a look at a solution I came up with to a problem, and advice if there are better ways to have gone about it.
To make a long story short around 20K pieces of... (2 Replies)
Hi ,
Im trying to monitor 2 instancesof a process on our solaris server and trying to do a notification if the returned process size is greater than 500M.
Since there are two variables returned I want to make use of arrays to check each and every variable that is stored. the issue that im facing... (2 Replies)
using bash Tru64...
converting DCL to shell...
any tips to make this work would be greatly appreciated.
Below is my failed attempt to assign command line input to variables by first declaring an array. I use a counter to create unique variables in a loop through the array. I need to call... (3 Replies)