Sponsored Content
Top Forums Shell Programming and Scripting merging of 2 files AWK, SHELL or something else Post 302159684 by pp56825 on Friday 18th of January 2008 07:46:06 AM
Old 01-18-2008
Yes i know that now our primary key will be $8
so now awk will looks like that:
BEGIN {
printf "%-3s|%-10s|%-4s|%-9s|%-9s|%-9s|%-70s|%-9s|%-s\n", "Cnt", "VT", "STAT", "Date", "Time","From","Alert Message","Instance",""
}
NR == FNR {
x[$1,$8]
y[$8] = $2
z[$8] = $3
next
}
!(($1,$8) in x) {
if ($8 in y)
$2 = y[$8]
$3 = z[$8]
printf "%-3s|%-10s|%-4s|%-9s|%-9s|%-9s|%-70s|%-9s|%-s\n", $1, $2, $3, $4, $5, $7, $8, $9, "" }

It's working!!!! Smilie
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging files with AWK filtering and counting lines

Hi there, I have a couple of files I need to merge. I can do a simple merge by concatenating them into one larger file. But then I need to filter the file to get a desired result. The output looks like this: TRNH 0000000010941 ORDH OADR OADR ORDL ENDT 1116399 000000003... (2 Replies)
Discussion started by: Meert
2 Replies

2. Shell Programming and Scripting

merging of 2 files AWK - part 2

i have try , but i think i will never learn awk :( now i have 2 files : a 1:aaa:2:aaa1 2:bbb:2:bbb1 3:ccc:3:ccc1 b aaa:2 bbb:0 ccc:3 output: for all lines where a.$2 == b.$1 i want to compare a.$3 != b.$2 if true then set err=1 if false set err=0 and print all lines from file a +... (2 Replies)
Discussion started by: pp56825
2 Replies

3. Shell Programming and Scripting

awk merging files based on 2 complex conditions

1. if the 1st row IDs of input1 (ID1/ID2.....) is equal to any IDNames of input2 print all relevant values together as defined in the output. 2. A bit tricky part is IDno in the output. All we need to do is numbering same kind of letters as 1 (aa of ID1) and different letters as 2 (ab... (4 Replies)
Discussion started by: ruby_sgp
4 Replies

4. Shell Programming and Scripting

awk command : row by row merging of two files

I want to write a scrpit to merge files row wise (actually concatinating) main.txt X Y Z file 1 A B C file 2 1 2 3 now i want the script to check if the file1 is empty or not, if empty then make it like A B C 1 2 3 again to check if second file is empty if not do as done... (0 Replies)
Discussion started by: shashi792
0 Replies

5. Shell Programming and Scripting

AWK Script For Merging Text Files

Hello, I am trying to merge data from two text files. One file (File1) contains a listing of data which includes the trial number in Column 5, while the other text file (File2) contains what category the trial belongs to. Here is a snippet of what File1 looks like. 1 Arrow_ST 9.738 0.905... (2 Replies)
Discussion started by: Jahn
2 Replies

6. Shell Programming and Scripting

merging files using awk

Hi, I have 2 files. File 1 chr1 1234 2468 ABC chr1 3456 4567 DEF chr2 5643 6154 XYZ : : : : so on.... File 2 chr1 1500 2500 positive chr1 2500 3500 negative chr1 3000 4500 neutral (10 Replies)
Discussion started by: Diya123
10 Replies

7. Shell Programming and Scripting

Merging two files in awk

Hi, How I can merge two file columns such as the followings using awk: file 1 2 3 2 2 1 1 file 2 4 3 4 5 7 6 Result: 2 3 4 3 2 2 4 5 1 1 7 6 This is an example, at the end, I will have about 25 files that I want to merge them, it is important for me that the order in the... (7 Replies)
Discussion started by: Homa
7 Replies

8. Shell Programming and Scripting

Merging rows in awk

Hello, I have a data format as follows: Ind1 0 1 2 Ind1 0 2 1 Ind2 1 1 0 Ind2 2 2 0 I want to use AWK to have this output: Ind1 00 12 21 Ind2 12 12 00 That is to merge each two rows with the same row names. Thank you very much in advance for your help. (8 Replies)
Discussion started by: Homa
8 Replies

9. Shell Programming and Scripting

Merging Files in UNIX shell script

I have the urge to merge some files using unix shell script but I'm very new using this language and I haven't succeeded yet. The requirement is to merge the header, body and footer into one file with the name "ANY-NAME" in below example. To identify which files should be merged, I have flagged... (9 Replies)
Discussion started by: black_soul
9 Replies

10. Shell Programming and Scripting

awk Merging multiple files with symbol representing new file

I just tried following ls *.dat|sort -t"_" -k2n,2|while read f1 && read f2; do awk '{print}' $f1 awk FNR==1'{print $1,$2,$3,$4,$5,"*","*","*" }' OFS="\t" $f2 awk '{print}' $f2 donegot following result 18-Dec-1983 11:45:00 AM 18.692 84.672 0 25.4 24 18-Dec-1983 ... (3 Replies)
Discussion started by: Akshay Hegde
3 Replies
CUBRID_FETCH_ARRAY(3)							 1						     CUBRID_FETCH_ARRAY(3)

cubrid_fetch_array - Fetch a result row as an associative array, a numeric array, or both

SYNOPSIS
array cubrid_fetch_array (resource $result, [int $type = CUBRID_BOTH]) DESCRIPTION
The cubrid_fetch_array(3) function is used to get a single row from the query result and returns an array. The cursor automatically moves to the next row after getting the result. PARAMETERS
o $result -$Result comes from a call to cubrid_execute(3) o $type -Array type of the fetched result CUBRID_NUM, CUBRID_ASSOC, CUBRID_BOTH. If you need to operate the lob object, you can use CUBRID_LOB. RETURN VALUES
Returns an array of strings that corresponds to the fetched row, when process is successful. FALSE, when there are no more rows; NULL, when process is unsuccessful. The type of returned array depends on how type is defined. By using CUBRID_BOTH (default), you'll get an array with both associative and number indices, and you can decide which data type to use by setting the $type argument. The $type variable can be set to one of the fol- lowing values: oCUBRID_NUM : Numerical array (0-based) oCUBRID_ASSOC : Associative array oCUBRID_BOTH : Numerical & Associative array (default) EXAMPLES
Example #1 cubrid_fetch_array(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb"); $req = cubrid_execute($conn, "SELECT name,area,seats,address FROM stadium WHERE nation_code='GRE' AND seats > 10000"); printf("%-40s %-10s %-6s %-20s ", "name", "area", "seats", "address"); while ($row = cubrid_fetch_array($req, CUBRID_NUM)) { printf("%-40s %-10s %-6s %-20s ", $row[0], $row[1], $row[2], $row[3]); } // if you want to operate LOB object, you can use cubrid_fetch_array($req, CUBRID_NUM | CUBRID_LOB) cubrid_close_request($req); cubrid_disconnect($conn); ?> The above example will output: name area seats address Panathinaiko Stadium 86300.00 50000 Athens, Greece Olympic Stadium 54700.00 13000 Athens, Greece Olympic Indoor Hall 34100.00 18800 Athens, Greece Olympic Hall 52400.00 21000 Athens, Greece Olympic Aquatic Centre 42500.00 11500 Athens, Greece Markopoulo Olympic Equestrian Centre 64000.00 15000 Markopoulo, Athens, Greece Faliro Coastal Zone Olympic Complex 34650.00 12171 Faliro, Athens, Greece Athens Olympic Stadium 120400.00 71030 Maroussi, Athens, Greece Ano Liossia 34000.00 12000 Ano Liosia, Athens, Greece SEE ALSO
cubrid_execute(3), cubrid_fetch(3), cubrid_fetch_row(3), cubrid_fetch_assoc(3), cubrid_fetch_object(3). PHP Documentation Group CUBRID_FETCH_ARRAY(3)
All times are GMT -4. The time now is 01:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy