I am having some trouble reading into an array. Basically, I am trying to grep for a pattern and extract it's value and store the same into an array. For eg., if my input is:
I grep for 'age' and want to extract 21 and store it in the array.
Here's the code I have come up with:
This does not seem to be working, and the program is going into infinite loop.
One thing I noticed is, if i comment out the below if loop:
then the contents do get stored in the array, but not uniquely. Means to say, if i have more records having age=21, then 21 gets stored in the array as many times as it is present in the input file. I would like this to be avoided, and no matter how many times age=21 is present, it should be stored just once.
Thanks in advance for helping..
Not going to bother looking into the guts of what you're trying to do. When you say your code is not working and going into an infinite loop, I don't know how that can be. I understand it doesn't work but I don't know how it's getting into an infinite loop.
- This
is not going to invoke the perl interpreter. It should try to run those commands under your shell.
- Looking at your input file, how will
ever match? How will it ever get to the heart of the code?
- This
may/may not be what you want but it will be empty anyway.
i have this basic code that i wrote to read a file and place it's values to an array. the source/input file will have multiple strings on it that is separated by a whitespace.
sample_list.txt file contents:
ACCT1 TABLE1
ACCT2 TABLE2
ACCT3 TABLE3
script file: sample_list.sh
... (3 Replies)
What is an efficient way of counting the number of unique values in a 400 column by 1000 row array and outputting the counts per column, assuming the unique values in the array are:
A, B, C, D
In other words the output should look like: Value COL1 COL2 COL3
A 50 51 52... (16 Replies)
I am reading a value from a file and want to store the value in a dynamic array as i don't know the number of occurrences of the value in that file.
How can i do that and then later fetch that value from array (25 Replies)
I have a file
root@server # cat /root/list12
11.22.33.44
22.33.44.55
33.44.55.66
33.44.55.66
33.44.55.66
I try to pass to array and display unique.
root@server# cat /root/test12.sh
#!/bin/bash
#delcare array badips and accumulate values to array elemenrs
badips=( $( cat... (4 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Hi,
I have requirement to assign values to variables which are created dynamically.
Below is the code which i am using to achieve above requirement.
#!/bin/ksh
oIFS="$IFS"; IFS=','
STR_FAIL_PARENT_IF_FAILS="WF_F_P_IF_FAILS1,WF_F_P_IF_FAILS2,WF_F_P_IF_FAILS3"
set -A... (1 Reply)
Hi All,
I'm writing a nagios check that will see if our ldap servers are in sync...
I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable
so...eg...let take the single array... (1 Reply)
Hi,
I want to put values in .txt file into array. Example :
$vi repo.txt
abc
def
ghi
jkl
mno
pqr
i want the output to be like this:
$echo ${mydf}
abc
$echo ${mydf}
def
$echo ${mydf}
ghi (3 Replies)
Hi,
I have a file like this:
Some_String_Here 123 123 123 321 321 321 3432 3221 557 886 321 321
I would like to find only the unique values in the files and get the following output:
Some_String_Here 123 321 3432 3221 557 886
I am trying to get this done using awk. Can someone please... (5 Replies)