filtering one file based on results from other- AGAIN


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting filtering one file based on results from other- AGAIN
# 1  
Old 12-13-2008
filtering one file based on results from other- AGAIN

I have asked this question here before and got the answer too. Unfortunately I used only one record as an example and the script works fine for one record but not for more than one record.



Can anybody help me with writing a script for the data that I want to use from one file based on the data from another file. I have file1 in this form;
FILE-1
======

DATA_444_0 -5219.34
DATA_451_0 -5189.74
DATA_445_0 -5176.06


(the first field represents a well name and the second field represents the depth of interest)
FILE2 is as follows (notice there are 4 fields each separated by a space, 2nd 3rd and 4th are numeric with 2 decimal places each);
==============
DATA_444_0 300088.53 2686300.75 1063.00
DATA_444_0 300088.59 2686300.75 891.00
DATA_444_0 300088.56 2686301.00 798.00
DATA_444_0 300088.47 2686301.00 705.00
DATA_444_0 300088.34 2686301.25 612.01
DATA_444_0 300088.28 2686301.25 520.01
DATA_444_0 300088.28 2686301.50 427.01
DATA_444_0 300088.31 2686301.75 335.01
DATA_444_0 300088.34 2686301.75 240.01
DATA_444_0 300088.44 2686301.75 146.01
DATA_444_0 300088.56 2686301.75 53.01
DATA_444_0 300088.75 2686301.75 -40.98
DATA_444_0 300088.91 2686301.75 -134.98
DATA_444_0 300089.00 2686301.50 -227.98
DATA_444_0 300089.06 2686301.25 -321.98
DATA_444_0 300089.09 2686301.25 -415.98
DATA_444_0 300089.00 2686301.00 -508.97
DATA_444_0 300088.75 2686300.75 -602.97
DATA_444_0 300088.38 2686300.50 -696.96
DATA_444_0 300087.94 2686300.25 -789.94
DATA_444_0 300087.41 2686300.00 -882.92
DATA_444_0 300086.91 2686300.00 -976.91
DATA_444_0 300086.41 2686299.75 -1070.89
DATA_444_0 300085.84 2686299.50 -1164.87
DATA_444_0 300085.28 2686299.50 -1257.85
DATA_444_0 300084.75 2686299.25 -1351.83
DATA_444_0 300084.25 2686299.00 -1445.81
DATA_444_0 300083.75 2686298.75 -1538.80
DATA_444_0 300083.25 2686298.50 -1632.78
DATA_444_0 300082.75 2686298.25 -1726.76
DATA_444_0 300082.25 2686297.75 -1820.74
DATA_444_0 300081.69 2686297.50 -1913.71
DATA_444_0 300081.00 2686297.25 -2007.68
DATA_444_0 300080.31 2686297.00 -2101.65
DATA_444_0 300079.66 2686296.75 -2194.62
DATA_444_0 300078.97 2686296.50 -2288.59
DATA_444_0 300077.72 2686296.25 -2381.49
DATA_444_0 300075.31 2686295.25 -2514.22
DATA_444_0 300073.56 2686294.75 -2607.03
DATA_444_0 300071.72 2686294.25 -2700.82
DATA_444_0 300069.94 2686293.50 -2794.61
DATA_444_0 300067.97 2686293.00 -2888.36
DATA_444_0 300065.72 2686292.50 -2981.06
DATA_444_0 300063.31 2686292.50 -3074.73
DATA_444_0 300061.09 2686292.50 -3168.45
DATA_444_0 300059.25 2686291.75 -3261.22
DATA_444_0 300057.78 2686290.50 -3355.00
DATA_444_0 300056.56 2686289.00 -3447.80
DATA_444_0 300055.44 2686287.75 -3541.63
DATA_444_0 300054.34 2686286.50 -3635.46
DATA_444_0 300053.22 2686285.00 -3729.28
DATA_444_0 300051.38 2686283.25 -3821.87
DATA_444_0 300047.81 2686280.25 -3914.58
DATA_444_0 300042.00 2686276.25 -4005.66
DATA_444_0 300033.97 2686271.25 -4093.28
DATA_444_0 300023.97 2686264.50 -4178.64
DATA_444_0 300012.50 2686256.50 -4260.66
DATA_444_0 300000.09 2686247.50 -4338.64
DATA_444_0 299987.09 2686237.75 -4416.07
DATA_444_0 299974.22 2686228.25 -4494.15
DATA_444_0 299961.19 2686219.25 -4571.27
DATA_444_0 299947.09 2686210.25 -4647.56
DATA_444_0 299932.34 2686201.00 -4722.21
DATA_444_0 299917.03 2686191.50 -4795.21
DATA_444_0 299900.72 2686181.75 -4864.32
DATA_444_0 299882.78 2686171.50 -4929.40
DATA_444_0 299863.28 2686160.25 -4987.74
DATA_444_0 299842.19 2686148.25 -5037.24
DATA_444_0 299820.22 2686135.25 -5077.83
DATA_444_0 299797.50 2686121.75 -5113.59
DATA_444_0 299774.62 2686107.75 -5146.67
DATA_444_0 299751.41 2686093.00 -5173.73
DATA_444_0 299727.69 2686078.00 -5191.84
DATA_444_0 299704.00 2686063.00 -5204.83
DATA_444_0 299683.09 2686049.50 -5214.66
DATA_444_0 299659.88 2686034.50 -5222.89
DATA_444_0 299646.31 2686026.00 -5226.55
DATA_444_0 299634.50 2686018.50 -5229.11
DATA_444_0 299622.41 2686010.75 -5230.46
DATA_444_0 299610.03 2686003.00 -5231.08
DATA_444_0 299598.22 2685995.50 -5232.39
DATA_444_0 299585.94 2685987.50 -5234.37
DATA_444_0 299574.16 2685980.00 -5235.77
DATA_444_0 299562.19 2685972.00 -5237.34
DATA_444_0 299550.38 2685964.00 -5238.75
DATA_444_0 299538.47 2685956.00 -5239.30
DATA_444_0 299526.88 2685948.00 -5240.25
DATA_444_0 299503.03 2685932.25 -5242.60
DATA_444_0 299478.84 2685916.75 -5244.89
DATA_444_0 299454.59 2685902.25 -5247.00
DATA_444_0 299429.75 2685888.00 -5248.53
DATA_444_0 299405.00 2685874.00 -5250.21
DATA_444_0 299380.03 2685860.00 -5251.42
DATA_444_0 299355.34 2685845.50 -5252.52
DATA_444_0 299330.84 2685830.75 -5252.61
DATA_444_0 299306.84 2685815.50 -5253.36
DATA_444_0 299282.72 2685800.25 -5254.86
DATA_444_0 299258.69 2685784.50 -5256.44
DATA_444_0 299234.91 2685769.25 -5258.01
DATA_444_0 299210.66 2685754.00 -5259.03
DATA_444_0 299186.31 2685738.75 -5261.28
DATA_444_0 299162.19 2685724.00 -5262.40
DATA_444_0 299137.78 2685709.00 -5263.17
DATA_444_0 299113.47 2685693.75 -5265.95
DATA_444_0 299089.41 2685678.75 -5269.02
DATA_444_0 299065.12 2685663.75 -5273.09
DATA_444_0 299040.91 2685648.50 -5277.33
DATA_444_0 299016.88 2685632.75 -5279.39
DATA_444_0 299004.41 2685624.75 -5280.02
DATA_444_0 298993.22 2685617.25 -5281.00
DATA_444_0 298981.09 2685609.00 -5282.87
DATA_444_0 298969.53 2685601.25 -5284.39
DATA_444_0 298945.75 2685585.25 -5286.33
DATA_444_0 298934.06 2685577.50 -5287.40
DATA_444_0 298921.88 2685569.25 -5288.62
DATA_444_0 298910.22 2685561.50 -5289.83
DATA_444_0 298898.34 2685553.50 -5290.93
DATA_444_0 298886.84 2685545.50 -5292.52
DATA_444_0 298874.94 2685537.00 -5294.01
DATA_444_0 298851.81 2685520.25 -5295.14
DATA_444_0 298828.75 2685503.75 -5294.69
DATA_444_0 298805.16 2685487.50 -5295.12
DATA_444_0 298781.47 2685471.25 -5297.46
DATA_444_0 298762.22 2685458.50 -5298.76
DATA_444_0 298733.69 2685440.75 -5299.62
DATA_444_0 298709.44 2685426.25 -5300.28
DATA_444_0 298685.84 2685410.00 -5303.39
DATA_444_0 298663.16 2685393.00 -5306.96
DATA_444_0 298640.28 2685375.75 -5307.87
DATA_444_0 298617.22 2685358.75 -5308.78
DATA_444_0 298593.59 2685342.50 -5311.02
DATA_444_0 298569.38 2685327.75 -5312.86
DATA_444_0 298544.44 2685313.75 -5313.74
DATA_444_0 298519.69 2685299.25 -5314.81
DATA_444_0 298495.38 2685284.25 -5317.08
DATA_444_0 298471.16 2685269.50 -5318.81
DATA_444_0 298446.28 2685255.25 -5319.94
DATA_444_0 298421.50 2685241.00 -5322.04
DATA_444_0 298397.31 2685226.25 -5323.91
DATA_444_0 298373.22 2685210.75 -5325.47
DATA_444_0 298349.03 2685195.25 -5327.70
DATA_444_0 298324.19 2685181.00 -5328.09
DATA_444_0 298299.31 2685167.50 -5327.37
DATA_444_0 298274.31 2685153.50 -5327.23
DATA_444_0 298249.44 2685139.25 -5328.05
DATA_444_0 298224.44 2685125.25 -5329.50
DATA_444_0 298209.47 2685117.00 -5329.49
DATA_445_0 299634.41 2683603.50 1073.00
DATA_445_0 299634.41 2683603.25 939.00
DATA_445_0 299634.38 2683603.25 849.00
DATA_445_0 299634.34 2683603.25 760.00
DATA_445_0 299634.34 2683603.25 639.00
DATA_445_0 299634.31 2683603.25 550.00
DATA_445_0 299634.28 2683603.25 455.00
DATA_445_0 299634.28 2683603.25 364.00
DATA_445_0 299634.28 2683603.50 274.00
DATA_445_0 299634.31 2683603.75 184.00
DATA_445_0 299634.34 2683603.75 94.01
DATA_445_0 299634.47 2683604.00 -0.99
DATA_445_0 299634.66 2683604.25 -94.99
DATA_445_0 299634.91 2683604.25 -189.98
DATA_445_0 299635.22 2683604.50 -283.97
DATA_445_0 299635.50 2683604.75 -379.97
DATA_445_0 299635.84 2683605.00 -474.95
DATA_445_0 299636.22 2683605.50 -569.94
DATA_445_0 299636.56 2683605.75 -664.93
DATA_445_0 299636.81 2683606.25 -758.91
DATA_445_0 299636.97 2683606.50 -853.91
DATA_445_0 299637.00 2683607.00 -948.90
DATA_445_0 299636.94 2683607.25 -1043.89
DATA_445_0 299636.84 2683607.75 -1138.88
DATA_445_0 299636.69 2683608.25 -1233.86
DATA_445_0 299636.53 2683609.00 -1328.84
DATA_445_0 299636.38 2683609.50 -1423.81
DATA_445_0 299636.31 2683610.25 -1517.77
DATA_445_0 299636.34 2683611.25 -1612.73
DATA_445_0 299636.47 2683612.00 -1707.69
DATA_445_0 299636.75 2683612.50 -1800.67
DATA_445_0 299637.16 2683612.50 -1895.66
DATA_445_0 299637.62 2683612.50 -1989.65
DATA_445_0 299638.06 2683612.75 -2080.64
DATA_445_0 299638.47 2683612.75 -2175.63
DATA_445_0 299638.78 2683612.75 -2269.62
DATA_445_0 299639.09 2683612.75 -2364.62
DATA_445_0 299639.50 2683612.75 -2458.61
DATA_445_0 299639.84 2683612.75 -2551.60
DATA_445_0 299640.16 2683612.75 -2646.60
DATA_445_0 299640.44 2683612.75 -2740.59
DATA_445_0 299640.78 2683613.00 -2835.58
DATA_445_0 299641.09 2683613.00 -2930.58
DATA_445_0 299641.44 2683613.25 -3024.57
DATA_445_0 299641.78 2683613.25 -3119.56
DATA_445_0 299641.91 2683613.50 -3159.56
DATA_445_0 299642.28 2683613.50 -3272.55
DATA_445_0 299642.53 2683613.75 -3362.54
DATA_445_0 299640.97 2683613.75 -3456.34
DATA_445_0 299636.16 2683613.25 -3553.02
DATA_445_0 299629.72 2683612.50 -3645.59
DATA_445_0 299622.97 2683611.50 -3735.89
DATA_445_0 299615.72 2683610.25 -3825.66
DATA_445_0 299606.91 2683608.25 -3916.98
DATA_445_0 299596.72 2683606.25 -4004.55
DATA_445_0 299584.50 2683604.00 -4090.35
DATA_445_0 299570.59 2683601.50 -4173.26
DATA_445_0 299556.56 2683599.50 -4252.64
DATA_445_0 299542.88 2683597.75 -4335.00
DATA_445_0 299529.72 2683595.75 -4418.23
DATA_445_0 299516.06 2683593.50 -4498.25
DATA_445_0 299500.16 2683590.75 -4578.32
DATA_445_0 299483.16 2683587.75 -4650.76
DATA_445_0 299463.06 2683584.50 -4722.36
DATA_445_0 299442.75 2683581.00 -4783.30
DATA_445_0 299419.41 2683577.25 -4843.20
DATA_445_0 299396.16 2683573.75 -4894.97
DATA_445_0 299371.81 2683569.75 -4940.85
DATA_445_0 299345.41 2683565.25 -4982.00
DATA_445_0 299319.66 2683561.00 -5015.37
DATA_445_0 299292.91 2683556.00 -5045.00
DATA_445_0 299265.22 2683551.00 -5071.22
DATA_445_0 299238.34 2683546.50 -5092.53
DATA_445_0 299210.34 2683541.50 -5110.47
DATA_445_0 299182.47 2683536.25 -5124.67
DATA_445_0 299170.59 2683534.25 -5129.91
DATA_445_0 299154.84 2683531.25 -5136.41
DATA_445_0 299141.75 2683528.75 -5141.46
DATA_445_0 299127.16 2683526.00 -5146.67
DATA_445_0 299098.53 2683520.75 -5156.24
DATA_445_0 299089.59 2683519.00 -5159.19
DATA_445_0 299086.03 2683518.25 -5160.34
DATA_445_0 299048.41 2683511.25 -5170.73
DATA_445_0 299018.97 2683506.50 -5178.30
DATA_445_0 298991.22 2683503.50 -5185.22
DATA_445_0 298963.59 2683501.50 -5190.69
DATA_445_0 298934.97 2683501.00 -5195.75
DATA_445_0 298906.12 2683500.25 -5203.57
DATA_445_0 298876.69 2683499.75 -5212.19
DATA_445_0 298848.06 2683499.50 -5215.89
DATA_445_0 298818.84 2683499.75 -5219.44
DATA_445_0 298790.50 2683499.75 -5223.13
DATA_445_0 298762.19 2683499.50 -5226.96
DATA_445_0 298733.28 2683499.25 -5231.53
DATA_445_0 298704.94 2683499.00 -5235.07
DATA_445_0 298676.03 2683498.50 -5238.58
DATA_445_0 298647.09 2683497.75 -5242.18
DATA_445_0 298619.06 2683497.75 -5245.56
DATA_445_0 298590.75 2683497.75 -5248.66
DATA_445_0 298562.47 2683497.50 -5254.95
DATA_445_0 298533.94 2683496.75 -5263.04
DATA_445_0 298505.03 2683496.25 -5269.21
DATA_445_0 298476.41 2683496.00 -5273.22
DATA_445_0 298448.12 2683496.50 -5278.47
DATA_445_0 298419.81 2683497.25 -5282.86
DATA_445_0 298391.47 2683498.00 -5283.31
DATA_445_0 298361.94 2683498.50 -5285.64
DATA_445_0 298333.03 2683499.00 -5290.84
DATA_445_0 298304.41 2683499.50 -5295.00
DATA_445_0 298275.78 2683500.00 -5297.91
DATA_445_0 298246.56 2683500.75 -5301.85
DATA_445_0 298218.22 2683501.75 -5303.61
DATA_445_0 298189.91 2683502.50 -5303.87
DATA_445_0 298161.25 2683503.25 -5305.82
DATA_445_0 298132.31 2683503.75 -5307.74
DATA_445_0 298103.97 2683504.00 -5310.00
DATA_445_0 298075.38 2683504.50 -5314.37
DATA_445_0 298047.06 2683505.00 -5319.01
DATA_445_0 298018.44 2683506.25 -5320.42
DATA_445_0 297989.84 2683507.25 -5323.86
DATA_445_0 297961.25 2683508.00 -5329.88
DATA_445_0 297932.97 2683509.50 -5332.40
DATA_445_0 297904.06 2683511.25 -5332.43
DATA_445_0 297875.72 2683512.25 -5332.94
DATA_445_0 297847.38 2683512.50 -5334.84
DATA_445_0 297819.06 2683512.25 -5336.68
DATA_445_0 297790.41 2683511.75 -5337.05
DATA_445_0 297761.44 2683511.75 -5336.17
DATA_445_0 297732.81 2683511.75 -5336.51
DATA_445_0 297704.47 2683511.75 -5338.22
DATA_445_0 297675.81 2683512.00 -5338.38
DATA_445_0 297646.56 2683512.50 -5337.05
DATA_445_0 297618.22 2683512.75 -5337.21
DATA_445_0 297589.56 2683513.25 -5337.69
DATA_445_0 297561.22 2683513.75 -5338.95
DATA_445_0 297532.88 2683513.75 -5340.96
DATA_445_0 297494.47 2683513.75 -5341.49
DATA_451_0 299841.66 2685174.75 1061.00
DATA_451_0 299841.84 2685174.75 953.00
DATA_451_0 299842.16 2685174.75 863.01
DATA_451_0 299842.47 2685175.00 769.02
DATA_451_0 299842.78 2685175.25 678.03
DATA_451_0 299843.03 2685175.50 614.03
DATA_451_0 299843.31 2685175.50 522.04
DATA_451_0 299843.62 2685175.75 427.05
DATA_451_0 299843.97 2685175.75 335.05
DATA_451_0 299844.34 2685176.00 242.06
DATA_451_0 299844.75 2685176.00 150.07
DATA_451_0 299845.19 2685176.00 58.08
DATA_451_0 299845.62 2685176.00 -33.91
DATA_451_0 299846.03 2685176.00 -126.90
DATA_451_0 299846.38 2685176.00 -221.89
DATA_451_0 299846.69 2685175.75 -316.88
DATA_451_0 299847.00 2685175.75 -410.87
DATA_451_0 299847.31 2685175.50 -505.86
DATA_451_0 299847.62 2685175.25 -600.86
DATA_451_0 299847.91 2685175.00 -691.85
DATA_451_0 299848.19 2685175.00 -786.85
DATA_451_0 299848.47 2685174.75 -881.84
DATA_451_0 299848.78 2685174.50 -975.83
DATA_451_0 299849.12 2685174.25 -1070.82
DATA_451_0 299849.47 2685174.25 -1166.81
DATA_451_0 299849.84 2685174.00 -1260.80
DATA_451_0 299850.19 2685173.50 -1355.79
DATA_451_0 299850.41 2685173.25 -1449.78
DATA_451_0 299850.53 2685172.75 -1544.77
DATA_451_0 299850.56 2685172.25 -1639.75
DATA_451_0 299850.56 2685171.50 -1734.73
DATA_451_0 299850.50 2685171.00 -1829.70
DATA_451_0 299850.44 2685170.25 -1924.67
DATA_451_0 299850.44 2685169.50 -2019.64
DATA_451_0 299850.47 2685168.50 -2114.60
DATA_451_0 299850.50 2685167.75 -2209.56
DATA_451_0 299850.47 2685167.00 -2304.52
DATA_451_0 299850.50 2685166.00 -2399.47
DATA_451_0 299850.53 2685165.25 -2492.43
DATA_451_0 299850.56 2685164.50 -2586.41
DATA_451_0 299850.72 2685164.50 -2681.41
DATA_451_0 299850.97 2685164.75 -2776.40
DATA_451_0 299851.16 2685165.00 -2870.40
DATA_451_0 299851.28 2685165.00 -2965.40
DATA_451_0 299851.38 2685165.00 -3055.40
DATA_451_0 299850.62 2685164.25 -3184.34
DATA_451_0 299848.53 2685163.25 -3278.00
DATA_451_0 299844.91 2685161.50 -3372.08
DATA_451_0 299840.34 2685159.50 -3465.66
DATA_451_0 299835.09 2685157.75 -3558.89
DATA_451_0 299828.94 2685156.00 -3651.56
DATA_451_0 299821.94 2685154.00 -3742.46
DATA_451_0 299813.78 2685151.25 -3834.22
DATA_451_0 299804.62 2685147.75 -3922.44
DATA_451_0 299793.94 2685142.50 -4010.23
DATA_451_0 299782.06 2685136.00 -4093.06
DATA_451_0 299768.38 2685128.00 -4173.61
DATA_451_0 299753.25 2685118.75 -4247.28
DATA_451_0 299736.97 2685108.25 -4318.08
DATA_451_0 299721.25 2685098.00 -4389.08
DATA_451_0 299706.47 2685088.25 -4464.25
DATA_451_0 299692.31 2685079.00 -4540.00
DATA_451_0 299677.44 2685069.00 -4614.78
DATA_451_0 299661.72 2685058.00 -4687.22
DATA_451_0 299645.53 2685046.25 -4754.17
DATA_451_0 299628.50 2685033.25 -4818.54
DATA_451_0 299610.53 2685020.50 -4879.98
DATA_451_0 299591.00 2685007.25 -4936.89
DATA_451_0 299570.72 2684994.25 -4988.96
DATA_451_0 299549.59 2684980.50 -5036.42
DATA_451_0 299527.72 2684966.75 -5076.78
DATA_451_0 299505.12 2684953.00 -5109.49
DATA_451_0 299481.03 2684938.50 -5136.28
DATA_451_0 299456.78 2684924.00 -5157.79
DATA_451_0 299430.94 2684909.25 -5174.27
DATA_451_0 299418.97 2684902.75 -5179.15
DATA_451_0 299406.41 2684896.00 -5182.37
DATA_451_0 299394.34 2684889.50 -5185.04
DATA_451_0 299381.78 2684882.75 -5188.23
DATA_451_0 299369.53 2684876.00 -5191.90
DATA_451_0 299357.28 2684869.25 -5194.87
DATA_451_0 299332.78 2684855.50 -5197.94
DATA_451_0 299308.25 2684842.00 -5199.79
DATA_451_0 299283.94 2684828.00 -5202.23
DATA_451_0 299259.88 2684813.75 -5203.64
DATA_451_0 299236.19 2684798.75 -5206.44
DATA_451_0 299211.62 2684783.00 -5210.88
DATA_451_0 299188.81 2684768.75 -5214.01
DATA_451_0 299165.03 2684754.00 -5219.76
DATA_451_0 299141.31 2684739.25 -5225.48
DATA_451_0 299117.56 2684724.25 -5228.27
DATA_451_0 299093.34 2684708.50 -5230.19
DATA_451_0 299069.16 2684692.00 -5232.21
DATA_451_0 299044.94 2684675.50 -5232.85
DATA_451_0 299020.59 2684659.50 -5233.74
DATA_451_0 298996.00 2684643.50 -5235.18
DATA_451_0 298971.53 2684628.00 -5237.40
DATA_451_0 298946.75 2684612.50 -5240.52
DATA_451_0 298922.00 2684597.00 -5243.93
DATA_451_0 298897.94 2684581.50 -5248.99
DATA_451_0 298873.56 2684565.25 -5254.13
DATA_451_0 298849.31 2684549.00 -5256.18
DATA_451_0 298825.06 2684532.75 -5255.26
DATA_451_0 298800.97 2684516.00 -5253.50
DATA_451_0 298777.19 2684499.00 -5255.38
DATA_451_0 298753.94 2684481.75 -5258.46
DATA_451_0 298730.50 2684464.25 -5260.13
DATA_451_0 298706.91 2684447.00 -5263.30
DATA_451_0 298682.78 2684430.50 -5266.31
DATA_451_0 298658.38 2684414.50 -5270.20
DATA_451_0 298633.97 2684398.75 -5273.77
DATA_451_0 298609.16 2684383.50 -5276.91
DATA_451_0 298584.28 2684368.00 -5280.08
DATA_451_0 298559.31 2684352.75 -5282.45
DATA_451_0 298534.22 2684337.75 -5284.99
DATA_451_0 298509.03 2684322.75 -5286.66
DATA_451_0 298484.44 2684308.25 -5288.89
DATA_451_0 298459.72 2684293.25 -5292.58
DATA_451_0 298434.81 2684277.75 -5296.59
DATA_451_0 298410.03 2684262.75 -5299.70
DATA_451_0 298384.97 2684247.75 -5301.74
DATA_451_0 298359.91 2684232.75 -5302.87
DATA_451_0 298335.06 2684217.75 -5304.29
DATA_451_0 298310.19 2684203.00 -5306.78
DATA_451_0 298285.06 2684188.00 -5309.63
DATA_451_0 298260.28 2684173.00 -5312.72
DATA_451_0 298235.31 2684157.75 -5315.31
DATA_451_0 298210.53 2684143.00 -5316.62
DATA_451_0 298185.69 2684128.00 -5317.65
DATA_451_0 298171.03 2684119.25 -5318.86


I want to filter the file2 in a way that it only puts out the data where column 4 in the file2 is less than or equal to the second column in file 1. Thus for the first record in file 1 ie DATA_444_0 -5219.34, then I want the file2 to be filtered so that it outputs the data starting from

DATA_444_0 299659.88 2686034.50 -5222.89
DATA_444_0 299646.31 2686026.00 -5226.55
DATA_444_0 299634.50 2686018.50 -5229.11
DATA_444_0 299622.41 2686010.75 -5230.46
.......
.......
.......

Similarly based on the second record in file 1 i.e.
DATA_451_0 -5189.74

the file 2 should be filtered and start from following line for this record
DATA_451_0 299369.53 2684876.00 -5191.90
DATA_451_0 299357.28 2684869.25 -5194.87
DATA_451_0 299332.78 2684855.50 -5197.94
........
........
........

and based on the third record in file 1 i.e.
DATA_445_0 -5176.06

The file2 should be filtered and start from following line for this record;

DATA_445_0 299018.97 2683506.50 -5178.30
DATA_445_0 298991.22 2683503.50 -5185.22
DATA_445_0 298963.59 2683501.50 -5190.69
DATA_445_0 298934.97 2683501.00 -5195.75
DATA_445_0 298906.12 2683500.25 -5203.57
DATA_445_0 298876.69 2683499.75 -5212.19

...........
..........


Thanks for your help on this. I am really stuck please help.
# 2  
Old 12-13-2008
Hi!
Oh this would be so easy if it wasn't for those decimals! Smilie
If You can find a way to handle decimals then here's a solution. It's using "dynamic" variable names.

I edited the files to eliminate decimal values and the decimal point in the values we use. And so I came up with this, and it works:

Code:
#!/bin/bash
#First create a variable for each entry in the first column with a value of the second column
while read a b;do export $a=$b;done < file4

#Now we can loop through the second file to see if a value in column four is -le to the value
#of a variable named as in column one
while read a b c d;do [ $d -le ${!a} ] && echo $a $b $c $d;done <file3

I tried using bc for the math but I couldn't really get something working. Maybe You can take it from here?

/Lakris
# 3  
Old 12-13-2008
Use nawk or /usr/xpg4/bin/awk on Solaris:

Code:
awk 'NR == FNR { 
  _[$1] = $2
  next
  }
$1 in _ && $4 <= _[$1]
' file1 file2


Last edited by radoulov; 12-14-2008 at 06:15 AM..
# 4  
Old 12-14-2008
Thanks a lot

Thank a lot both of you guys. Rodulov, I want to specially thank you as your script worked without anymore modification of the script. Perfectly done. Thanks a lot. Can I ask you one more question, after running your script I have a file in which there are lots of records that only occur once (It is normal for my data), I would like to run an awk (or any other command) to get rid of the records that only occur once (after I run Rodulov's script). Can somebody help me. For example I might have the data as follows;

So from the following data;
I would like to delete the Line 1, 2, 3, 4, 5, 6 and 7 but keep the rest as these the records on line 1, 2, 3, 4, 5, 6 and 7 occur only once (based on the first column). I would appreciate your help on this one.


DATA_96_0 315367.47 2711845.75 -6439.36
DATA_97_0 314705.38 2706544.75 -6480.00
DATA_98_0 314541.81 2717794.50 -6015.30
DATA_99_0 315198.31 2710142.75 -6416.00
DATA_9_0 299511.28 2719683.50 -6525.00
DATA_8_0 309508.59 2719213.25 -5422.90
DATA_84_0 318521.03 2722324.75 -7028.00
DATA_85_0 318399.84 2720022.25 -6658.59
DATA_85_0 318398.53 2720050.00 -6666.37
DATA_85_0 318396.75 2720078.50 -6670.63
DATA_85_0 318394.91 2720106.75 -6675.82
DATA_85_0 318393.62 2720135.00 -6684.01
DATA_85_0 318393.22 2720162.25 -6693.65
DATA_85_0 318393.22 2720190.75 -6706.62
DATA_85_0 318393.06 2720219.25 -6720.19
DATA_85_0 318392.25 2720247.00 -6732.92
DATA_85_0 318390.88 2720275.00 -6745.86
DATA_85_0 318389.41 2720301.00 -6755.37
# 5  
Old 12-14-2008
OK,
you can try something like this:

Code:
awk 'END {
  for(i=1; i<=c; i++) {
    split(r[i], t)
	if (u[t[1]] > 1)
	  print r[i]
	  }
  }
NR == FNR { 
  _[$1] = $2 
  next 
  }
$1 in _ && $4 <= _[$1] {
  r[++c] = $0
  u[$1]++
}' file1 file2


Last edited by radoulov; 12-14-2008 at 09:04 AM..
# 6  
Old 12-15-2008
Thanks a lot.... AGAIN

Radoulov,

That is perfect solution for my need. Man you are a superman. Bieng a newbie to UNIX / LINUX, I would never have figured that out. Thanks a million man. God Bless.
# 7  
Old 12-15-2008
I now have to also sum the values (absolute values) in the last column based on each record in the first coloumn. i.e. after running your script, if I got;


DATA_444_0 299659.88 2686034.50 -5222.89
DATA_444_0 299646.31 2686026.00 -5226.55
DATA_444_0 299634.50 2686018.50 -5229.11
DATA_444_0 299622.41 2686010.75 -5230.46
DATA_451_0 299369.53 2684876.00 -5191.90
DATA_451_0 299357.28 2684869.25 -5194.87
DATA_451_0 299332.78 2684855.50 -5197.94


then i would want to ouput the file with the first record (only once and the sum of the last column until the record in the first column changes i.e
DATA_444_0 -20909.01
DATA_451_0 -15584.71

............
............


Hope you would not mind helping me with this one too.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Filtering records of a csv file based on a value of a column

Hi, I tried filtering the records in a csv file using "awk" command listed below. awk -F"~" '$4 ~ /Active/{print }' inputfile > outputfile The output always has all the entries. The same command worked for different users from one of the forum links. content of file I was... (3 Replies)
Discussion started by: sunilmudikonda
3 Replies

2. UNIX for Beginners Questions & Answers

Filtering based on column values

Hi there, I am trying to filter a big file with several columns using values on a column with values like (AC=5;AN=10;SF=341,377,517,643,662;VRT=1). I wont to filter the data based on SF= values that are (bigger than 400) ... (25 Replies)
Discussion started by: daashti
25 Replies

3. Shell Programming and Scripting

Filtering duplicates based on lookup table and rules

please help solving the following. I have access to redhat linux cluster having 32gigs of ram. I have duplicate ids for variable names, in the file 1,2 are duplicates;3,4 and 5 are duplicates;6 and 7 are duplicates. My objective is to use only the first occurrence of these duplicates. Lookup... (4 Replies)
Discussion started by: ritakadm
4 Replies

4. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

5. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

6. Shell Programming and Scripting

Perl: filtering lines based on duplicate values in a column

Hi I have a file like this. I need to eliminate lines with first column having the same value 10 times. 13 18 1 + chromosome 1, 122638287 AGAGTATGGTCGCGGTTG 13 18 1 + chromosome 1, 128904080 AGAGTATGGTCGCGGTTG 13 18 1 - chromosome 14, 13627938 CAACCGCGACCATACTCT 13 18 1 + chromosome 1,... (5 Replies)
Discussion started by: polsum
5 Replies

7. Shell Programming and Scripting

filtering records based on numeric field value in 8th position

I have a ";" delimited file.Whcih conatins a number fileds of length 4 charcters in 8th position But there is a alphanumeric charcters like : space, ";" , "," , "/" , "23-1" , "23 1" , "aqjhdj" , "jun-23" , "APR-04" , "4:00AM" , "-234" , "56784 ", "." , "+" "_" , "&" , "*" , "^" , "%" , "!"... (2 Replies)
Discussion started by: indusri
2 Replies

8. Shell Programming and Scripting

filtering one file based on results from other

Can anybody help me with writing a script for the data that I want to use from one file based on the data from another file. I have file1 in this form; (the first field represents a well name and the second field represents the depth of interest) FILE1 -------- DATA_35_0 ... (2 Replies)
Discussion started by: digipak
2 Replies

9. UNIX for Dummies Questions & Answers

Filtering records of a file based on a value of a column

Hi all, I would like to extract records of a file based on a condition. The file contains 47 fields, and I would like to extract only those records that match a certain value in one of the columns, e.g. COL1 COL2 COL3 ............... COL47 1 XX 45 ... (4 Replies)
Discussion started by: risk_sly
4 Replies

10. Shell Programming and Scripting

filtering list results

I created a large file list using: find . -type f -mtime +540 > test2.txt ..which searched recursively down the directory tree searching for any file older than 540 days. I would like to filter the results removing the directory name and the "/" character, resulting in only a list of the... (3 Replies)
Discussion started by: fxvisions
3 Replies
Login or Register to Ask a Question