Help - Search - Members - Calendar
Full Version: Script for data editing
Linuxhelp > Support > Programming in Linux
Ohana
Hi All,
I need help with grepping specific lines in a data file and then saving them to a new file.
I would like to find and save any line in the data file that has two of the following strings in the first column:

P011 P028 RG09 RG10 RG11 RG12 RG13 P039

example -> 'P011_GPS-P028_GPS'

An example of the data:

P039_GPS-P040_GPS -0.30 0.64 0.10
P044_GPS-P040_GPS -0.10 -0.76 0.10
WHN1_GPS-P040_GPS 2.08 0.86 1.28
P038_GPS-P040_GPS -2.52 -2.18 0.92
TCUN_GPS-P040_GPS -0.31 -9.00 0.11
RG13_GPS-P040_GPS 1.35 2.98 0.11
P070_GPS-P040_GPS 0.49 0.08 0.13
RG24_GPS-P040_GPS -0.20 0.79 0.11
RG12_GPS-P040_GPS 0.01 1.58 0.11
RG08_GPS-P040_GPS -0.23 1.35 0.18
P037_GPS-P040_GPS -0.17 -0.34 0.09
RG03_GPS-P040_GPS 0.23 1.83 0.28
P035_GPS-P040_GPS -0.11 0.45 0.10
P041_GPS-P040_GPS -0.21 -0.47 0.10
RG23_GPS-P040_GPS -0.65 0.44 0.10
RG19_GPS-P040_GPS -0.48 -0.27 0.13
P120_GPS-P040_GPS -0.04 0.09 0.13
....

I've been trying to use a double for loop in bash to do it, but I haven't been able to figure it out.
Any help would be appreciated.
Thanks


darkob
QUOTE (Ohana @ May 9 2009, 06:44 PM) *
Hi All,
I need help with grepping specific lines in a data file and then saving them to a new file.
I would like to find and save any line in the data file that has two of the following strings in the first column:

P011 P028 RG09 RG10 RG11 RG12 RG13 P039

example -> 'P011_GPS-P028_GPS'

An example of the data:

P039_GPS-P040_GPS -0.30 0.64 0.10
P044_GPS-P040_GPS -0.10 -0.76 0.10
WHN1_GPS-P040_GPS 2.08 0.86 1.28
P038_GPS-P040_GPS -2.52 -2.18 0.92
TCUN_GPS-P040_GPS -0.31 -9.00 0.11
RG13_GPS-P040_GPS 1.35 2.98 0.11
P070_GPS-P040_GPS 0.49 0.08 0.13
RG24_GPS-P040_GPS -0.20 0.79 0.11
RG12_GPS-P040_GPS 0.01 1.58 0.11
RG08_GPS-P040_GPS -0.23 1.35 0.18
P037_GPS-P040_GPS -0.17 -0.34 0.09
RG03_GPS-P040_GPS 0.23 1.83 0.28
P035_GPS-P040_GPS -0.11 0.45 0.10
P041_GPS-P040_GPS -0.21 -0.47 0.10
RG23_GPS-P040_GPS -0.65 0.44 0.10
RG19_GPS-P040_GPS -0.48 -0.27 0.13
P120_GPS-P040_GPS -0.04 0.09 0.13
....

I've been trying to use a double for loop in bash to do it, but I haven't been able to figure it out.
Any help would be appreciated.
Thanks

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.