Sponsored Content
Top Forums Shell Programming and Scripting Problem in comparing 2 files string by string Post 302546534 by jitendra.pat04 on Thursday 11th of August 2011 11:19:07 AM
Old 08-11-2011
Its almost done friend

Hi Agama,

Its almost done,
now the only issues left are....
1) blanks are not getting printed....
2) and some of the columns that are entirely blank ie: having the values as "all zeros" are not needed.....
3) in some cases the Blank column is also having some values for hoz fields....I want those values also to be added to the vertical column having values 255......I am pasting the O/p for your reference......

###############################

Matrix: 1
COLA/COLB 5065 5294 5672 5673 8059 8505 8508 8549 8587 8600 8632 8649 8706 8709 8725 8739 8748 8778 8798 8822 9008 9404
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 127 1140 1 79 84574 17436 23729 47678 9758 36855 102332 40437 34852 11229 15867 0 26227 36353 120463 1099 2504 10
1 0 0 0 0 148 32 143 80 30 128 207 89 100 16 26 0 78 116 262 4 1 0
3 0 0 0 0 53 52 9 1002 1 233 111 36 357 124 23 0 62 117 1548 2 10 0
17 0 0 0 0 3126 747 2010 3406 600 3579 9757 2633 1966 457 1526 0 3294 2582 14497 299 495 0
19 25 169 0 31 6408 1426 2931 80023 625 4306 17609 4860 3354 1083 2089 0 2818 4125 10834 120 260 0
28 0 0 0 0 0 0 0 2 0 0 0 0 0 1 0 0 0 0 0 0 0 0
34 0 3 0 0 2928 736 860 2130 230 1625 2901 927 2976 842 572 0 625 2186 4527 27 23 0
38 0 0 0 0 2 0 0 26 0 6 2 13 4 1 5 0 2 2 7 1 1 0
131 0 0 0 0 7 0 1 0 0 0 10 6 1 0 1 0 0 5 16 0 4 0
133 0 6 0 21 3367 719 1188 3778 231 1014 3209 1943 1228 492 717 0 1513 1426 4204 113 74 0
137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
138 0 0 0 0 127 43 98 122 14 36 201 144 131 52 46 0 12 210 485 0 0 0
254 2 31 0 0 5386 928 1584 4428 621 2071 5126 2576 2324 633 1064 0 2022 2798 5221 80 116 0
255 0 4 0 0 1162 366 428 917 202 555 1408 471 782 190 332 0 396 617 1777 9 40 0

Matrix: 2
COLA/COLB 5065 5294 5672 5673 8059 8505 8508 8549 8587 8600 8632 8649 8706 8709 8725 8739 8748 8778 8798 8822 9008 9404
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 4038 0 1309 583 302 0 0 108 228 0 171 30293 208 341 0 11120 5149 0
1 0 0 0 0 275 0 0 2 10 0 0 4 4 0 24 1383 4 16 0 468 305 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 47 0 0
17 0 0 0 0 5 0 0 0 0 0 0 0 7 0 0 11 9 0 0 3 1 0
19 0 0 0 0 1828 0 24 27 31 0 0 0 23 0 13 439 20 61 0 1203 75 0
28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 0 0
34 0 0 0 0 87 0 165 0 22 0 0 22 2 0 0 2813 3 23 0 360 115 0
38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
133 0 0 0 0 825 0 43 75 27 0 0 15 85 0 105 1985 12 242 0 999 364 0
137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 0 0 0 0 1 0
138 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
254 0 0 0 0 175 0 31 7 8 0 0 4 8 0 4 473 3 10 0 239 85 0
255 0 0 0 0 41 0 9 1 3 0 0 0 3 0 2 138 2 1 0 74 14 0

Matrix: 3
COLA/COLB 5065 5294 5672 5673 8059 8505 8508 8549 8587 8600 8632 8649 8706 8709 8725 8739 8748 8778 8798 8822 9008 9404
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 987 0 0 0 413 3492 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 1 132 0
28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
133 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0
137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2 7 0
138 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
254 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 3 15 0
255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 1 24 0

Matrix: 5
COLA/COLB 5065 5294 5672 5673 8059 8505 8508 8549 8587 8600 8632 8649 8706 8709 8725 8739 8748 8778 8798 8822 9008 9404
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1772 126 877 1056 256 1413 3749 544 1549 481 152 0 998 746 4304 115 97 0
1 0 0 0 0 0 1 0 1 0 1 5 0 0 2 0 0 1 1 5 0 0 0
3 0 0 0 0 0 0 0 168 0 0 0 0 79 0 0 0 0 0 30 12 0 0
17 0 0 0 0 70 46 2 40 1 1 120 12 147 47 2 0 5 66 185 2 3 0
19 0 0 0 0 71 24 33 44 17 65 122 32 35 19 26 0 42 24 186 0 3 0
28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
34 0 0 0 0 2 0 50 1 0 0 2 0 9 6 1 0 0 0 16 0 0 0
38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
133 0 0 0 0 107 9 39 22 4 53 112 36 98 21 6 0 37 72 133 2 2 0
137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
138 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
254 0 0 0 0 88 36 29 34 11 37 107 28 47 11 12 0 29 32 58 2 2 0
255 0 0 0 0 100 14 40 95 7 25 153 27 48 11 4 0 28 51 181 0 3 0

Matrix: 6
COLA/COLB 5065 5294 5672 5673 8059 8505 8508 8549 8587 8600 8632 8649 8706 8709 8725 8739 8748 8778 8798 8822 9008 9404
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 210 0 0 0 0 0 0 0 0 0 0 6463 0 0 0 1025 566 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 62 0 0
28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
34 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 466 0 0 0 40 38 0
38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 0 0 0 3 5 0
131 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
133 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 245 0 0 0 120 75 0
137 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0
138 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
254 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 103 0 0 0 11 10 0
255 0 0 0 0 24 0 0 0 0 0 0 0 0 0 0 730 0 0 0 81 69 0

###################

Here the above most vertical entry is for "blank" but blank is not getting printed....also for the hoz value 8798, 1 count is in blank,,,I want this also to be added in vertical entry 255 ie: the last entry in vertical column.....
8739 in hoz array is having all entries as zero.....need to remove this.....

################################################
Also dear friend can u just give me some ideas how to learn to write such a nice and effective short length codes,,,,,as I am a newbie and do not have much ideas of C language......any links or pdf's wud be very very highly appreciated.....

Thanx in advance ....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

2. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies

3. Shell Programming and Scripting

problem in comparing numeric with string

Hi all, I am having a problem in comparing numeric value with string. I have a variable in my script which gets the value dynamically. It can be a numeric value or a string. I have to do separate task based on its value numeric or sting variable VARIABLE. I grep FILE_COUNT and obtained... (7 Replies)
Discussion started by: naren_0101bits
7 Replies

4. Shell Programming and Scripting

Problem comparing String using IF stmt

Hi frnds Im facing an issues while trying to compare string using IF stmt, my code is: chkMsgName=`Service Fee Detail` if then if then if then echo "Valid File Ready for processing" fi fi ... (5 Replies)
Discussion started by: balesh
5 Replies

5. Shell Programming and Scripting

Parsing a long string string problem for procmail

Hi everyone, I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email. Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string. GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies

6. UNIX for Dummies Questions & Answers

Comparing a String variable with a string literal in a Debian shell script

Hi All, I am trying to to compare a string variable with a string literal inside a loop but keep getting the ./testifstructure.sh: line 6: #!/bin/sh BOOK_LIST="BOOK1 BOOK2" for BOOK in ${BOOK_LIST} do if then echo '1' else echo '2' fi done Please use next... (1 Reply)
Discussion started by: daveu7
1 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

8. Shell Programming and Scripting

How to append a string by comparing another string?

Hi , I have one file like BUD,BDL BUDCAR BUD,BDL BUDLAMP ABC,CDF,KLT ABISKAR ABC,CDF,KLT CORNEL ABC,CDF,KLT KANNAD JKL,HNM,KTY,KJY JAGAN JKL,HNM,KTY,KJY HOUSE JKL,HNM,KTY,KJY KATAK JKL,HNM,KTY,KJY KOLKA The o/p should be like BUD,BDL BUDCAR,BUDLAMP ABC,CDF,KLT... (4 Replies)
Discussion started by: jagdishrout
4 Replies

9. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

10. UNIX for Advanced & Expert Users

Help comparing string, please

Good morning, I need compare this string. if || || ; then But this line not work, somebody can say me what is the error. Thank you for advanced. (5 Replies)
Discussion started by: systemoper
5 Replies
All times are GMT -4. The time now is 06:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy