awk arrays - compare value in second column to variable
Hello,
I am trying to redirect files to a directory by using a config file. The config files is as such:
and so on...
I have a variable that should match one of these IDs. I want to load this config file into an awk array, and then parse trhough it to find the record and then use the PathToDirectory to copy my file to it.
This is what I have:
Any thoughts? My idea is to fill the array, and then compare my AK202 variable to the second column, store the third as the destination directory.
Regards!
Last edited by radoulov; 04-09-2012 at 03:53 PM..
Reason: Code tags!
I've been banging my head against the wall to accomplish the following. Given two files:
File a.txt
12345 hello
32324 there
File b.txt
12345 stuff
45454 howdy
32324 joe
If column 1 matches between the two files, then print only the entire line of the 2nd file (b.txt in this... (3 Replies)
Hi
have an array like this
colarray="a"
colarray="b"
colarray="c"
colarray="d"
colarray="e"
colarray="f"
the arrayvariable is in unix sh file
i want to check the content of the array to oracle database table.
that is whether "a" is present in the table. (4 Replies)
Hi to everyone,
Please some help over here.
Hi have array a with 6 elements and array b with 3 elements as shown inside BEGIN{} statement.
I need help to get the correct sintax (the part in red) to compare if string from array b is in array a and print the number
related for each match.... (3 Replies)
Hi,
I have a table in unix from which i want to read the contents line by line, then filter out the values from 6th column one by one and compare it a fixed value.
How to do this? (7 Replies)
Hi,
I know that this topic has been discussed in the past and I've tried to follow all the guidelines. Anyhow, I following describe my problem.
I have a file (file1 , no. records = 67) containing pairs of IP addresses as follows (with single space as delimiter between the fields):
example... (5 Replies)
Hi All,
I have a file test.txt.
Content of test.txt :
1 vinay se
2 kumar sse
4 kishore tl
I am extracting the content of file with below command.
awk '$2 ~ "vinay" {print $0}' test.txt
Now instead of hardcoding $2 is there any way pass $2 as variable and compare with a... (7 Replies)
I need your help to discover missing elements for each box.
In theory each box should have 4 items: ITEM01, ITEM02, ITEM08, and ITEM10.
Some boxes either have a missing item (BOX02 ITEM08) or might have da duplicate item (BOX03 ITEM02) and missing another one (BOX03 ITEM01).
file01.txt
... (2 Replies)
Hi team,
I have below sample file. It has 4 columns. I want awk script to compare column2 and column4 row by row and print result in new column5
If value matches then result should be MATCHED
if not then result should be NOT MATCHED
Input file as below
UDC_MSISDN,UDC_NPREFIX... (9 Replies)
Example:
I have files in below format
file 1:
zxc,133,joe@example.com
cst,222,xyz@example1.com
File 2 Contains:
hxd
hcd
jws
zxc
cst
File 1 has 50000 lines and file 2 has around 30000 lines :
Expected Output has to be :
hxd
hcd
jws (5 Replies)
i'm new to awk, and i've been searching on the forum for sum of a column but all the scripts does sum a column of an entire file.
I've a file like this:
cat file.txt
1234 5678
5678 1234
I want to use awk to do sum of each column per line not entire file, compare the two then write the... (1 Reply)