Hello,
I would like to write a
/bin/ksh script to manipulate a file and compare its contexts. Comparing lines 1 & 2, 3 & 4, 5 & 6, and so forth until the end of the file. This is what I would like the script to compare (using line 1 & 2 as an example):
1. Verify if the last column in line 1 is numeric. If condition is true move it (15.235.10.21) to the beginning of the line. So it would now display
15.235.10.21 Alabama
2. If line 1, column 1 is numeric and line 2, column 1 is numeric compare both numbers. If both numbers match move on to the next (lines 3 & 4).
3. If the numbers do not match display all lines not matching at the end.
Original file contexts:
HTML Code:
Alabama 15.235.10.21
15.235.10.21
Petersburg 15.25.18.21
15.25.18.21
Salem 15.235.18.20
15.235.18.20
Tampa 15.235.18.20
15.235.18.20
Washington 15.235.18.21
15.235.18.21
Nova 15.235.18.21
15.234.18.21
Nashville 15.235.18.21
15.235.18.21
Texas 15.235.18.21
15.235.18.21
Burbank 15.235.18.25
15.235.18.25
Carolina 15.235.18.22
15.235.18.22
Seattle 15.235.18.23
15.235.18.23
Wyoming 15.235.18.24
15.235.18.24
Vermont 18.66.20.17
18.66.2.17
New York 13.5.48.2
columbia
Florida 13.7.24.25
13.7.24.25
Chicago 13.17.12.5
uchicago
Nebraska
Tennessee 16.13.3.2
plank
Frisco 15.35.18.1
Japan
Canada
France 18.55.7.25
18.55.7.25
Example script output if numbers dont match:
HTML Code:
The following do not match:
15.235.18.21 Nova
15.234.18.21
18.66.20.17 Vermont
18.66.2.17
Please advise, thank you.