1

I have a text file containing lines like:

1 STATION IU XMAS BHZ           -544.520         2.045      -157.446
1 STATION IU XMAS BHT           -544.520         2.045      -157.446
0 STATION IU XMAS BHR           -544.520         2.045      -157.446

When I try to print the lines containing, for example the matching string 'BHZ', as follows; awk '/BHZ/{ print}' tmp, awk does not print anything out.

Upon closer inspection with cat -v tmp, I found that these lines are formatted as follows;

1 STATION IU^@^@^@^@^@ XMAS^@^@^@ BHZ           -544.520         2.045      -157.446
1 STATION IU^@^@^@^@^@ XMAS^@^@^@ BHT           -544.520         2.045      -157.446
0 STATION IU^@^@^@^@^@ XMAS^@^@^@ BHR           -544.520         2.045      -157.446

When I try to remove these field separators using tr -d '\^@^@^@^@^@\^@^@^@' < tmp > tmp1, it removes all fields following IU:

e.g. after running tr, the output looks like

1 STATION IU
1 STATION IU
1 STATION IU

head -n 1 tmp | hexdump -C output is as follows

00000000  20 20 20 20 20 31 35 30  20 20 45 56 45 4e 54 20  |     150  EVENT |
00000010  20 20 20 20 20 20 20 20  20 34 38 2e 39 36 39 20  |         48.969 |
00000020  20 20 20 20 20 20 31 35  37 2e 36 39 31 20 20 20  |      157.691   |
00000030  20 20 20 20 20 35 35 2e  33 39 30 20 20 20 20 20  |     55.390     |
00000040  20 20 20 34 35 2e 33 39  30 20 20 20 20 20 20 20  |   45.390       |
00000050  20 34 34 2e 33 39 30 20  20 20 20 20 20 20 20 20  | 44.390         |
00000060  33 2e 37 34 32 20 20 20  20 35 30 2e 30 30 30 20  |3.742    50.000 |
00000070  20 20 20 20 31 2e 30 30  30 20 20 20 20 20 32 20  |    1.000     2 |
00000080  20 32 30 32 30 20 20 20  20 38 35 20 20 20 20 20  | 2020    85     |
00000090  33 20 20 20 20 32 35 20  20 20 20 20 32 20 20 20  |3    25     2   |
000000a0  20 34 39 20 20 20 20 32  30 20 20 20 20 20 30 20  | 49    20     0 |
000000b0  20 30 20 20 20 20 20 20  34 2e 30 30 20 20 20 20  | 0      4.00    |
000000c0  20 30 2e 30 30 30 30 30  45 2b 30 30 20 20 20 20  | 0.00000E+00    |
000000d0  20 30 2e 31 30 30 30 30  45 2b 30 31 20 20 20 20  | 0.10000E+01    |
000000e0  20 30 2e 31 31 35 34 37  45 2b 30 31 20 20 20 20  | 0.11547E+01    |
000000f0  2d 30 2e 35 37 37 33 35  45 2b 30 30 20 20 20 20  |-0.57735E+00    |
*
00000110  20 30 2e 30 30 30 30 30  45 2b 30 30 20 20 20 20  | 0.00000E+00    |
*
00000140  20 30 2e 31 37 33 32 31  45 2b 30 30 20 20 20 20  | 0.17321E+00    |
00000150  20 30 2e 37 34 34 33 30  45 2b 30 30 20 20 20 20  | 0.74430E+00    |
00000160  2d 30 2e 33 35 34 36 39  45 2b 30 30 20 20 20 20  |-0.35469E+00    |
00000170  2d 30 2e 33 38 39 36 30  45 2b 30 30 20 20 20 20  |-0.38960E+00    |
00000180  20 30 2e 31 35 34 39 32  45 2b 30 30 20 20 20 20  | 0.15492E+00    |
00000190  2d 30 2e 34 34 38 39 30  45 2b 30 30 20 20 20 20  |-0.44890E+00    |
000001a0  2d 30 2e 35 39 38 39 32  45 2b 30 30 20 20 20 20  |-0.59892E+00    |
000001b0  20 30 2e 34 35 31 32 36  45 2b 30 30 20 20 20 20  | 0.45126E+00    |
000001c0  2d 30 2e 33 36 32 35 32  45 2b 30 30 20 20 20 20  |-0.36252E+00    |
000001d0  2d 30 2e 38 38 37 34 33  45 2d 30 31 20 20 20 20  |-0.88743E-01    |
000001e0  20 30 2e 35 38 33 30 31  45 2d 30 32 20 20 20 20  | 0.58301E-02    |
000001f0  20 30 2e 38 33 39 31 39  45 2d 30 33 20 20 20 20  | 0.83919E-03    |
00000200  2d 30 2e 33 34 32 33 37  45 2b 30 30 20 20 20 20  |-0.34237E+00    |
00000210  20 30 2e 33 32 35 39 39  45 2b 30 30 20 20 20 20  | 0.32599E+00    |
00000220  20 30 2e 31 39 35 37 31  45 2b 30 30 20 20 20 20  | 0.19571E+00    |
00000230  20 30 2e 32 31 39 39 39  45 2b 30 30 20 20 20 20  | 0.21999E+00    |
00000240  20 30 2e 32 30 37 38 33  45 2b 30 30 20 20 20 20  | 0.20783E+00    |
00000250  20 30 2e 36 35 37 36 34  45 2b 30 30 20 20 20 20  | 0.65764E+00    |
00000260  20 30 2e 33 37 32 39 38  45 2b 30 30 20 20 20 20  | 0.37298E+00    |
00000270  20 31 20 20 20 20 32 37  20 20 20 20 20 32 34 2e  | 1    27     24.|
00000280  30 30 20 20 20 20 20 30  2e 39 37 38 35 35 45 2b  |00     0.97855E+|
00000290  32 37 20 20 20 20 20 30  2e 32 33 37 36 33 45 2b  |27     0.23763E+|
000002a0  32 38 20 20 20 20 20 31  31 37 0a                 |28     117.|
000002ab

I want to extract the fields following "^@^@^@^@^@" (e.g. XMAS) and "^@^@^@" (e.g. BHZ). How do I do this? I haven't encountered these non-printing field separators/formatting before.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
januka
  • 47
  • 1
  • 7

0 Answers0