Using Awk on an Unusual Character?
I need to process the fifth line on this text using awk:
Today Jan 21 Sun 22 Mon 23 Tue 24 Wed 25
Light Wintry Mix Partly Cloudy Showers Sunny Partly
Light Wintry Mix Partly Cloudy Showers Sunny Partly Cloudy
30°FHigh 35°High 52°High 45°High 43°High
18°Low 33°Low 39°Low 31°Low 30°Low
Chance of Precip:
100% Chance of Precip:
20% Chance of Rain:
60% Chance of Rain:
0% Chance of Rain:
Notice there are small circles between the numbers and the letters on the fifth line.
I have tried this:
° is the degree character. The actual binary data depends on what character set is used. In UTF-8 it is \xC2\xB0 and in ISO-8859-1, ISO-8859-15 and Windows-1252 it is \xB0 .
Let's assume you don't know the character set, and that you're only interested in getting the five numeric values (and nothing else) from the file using awk. The solution is simple: use a field separator that includes the "degrees Fahrenheit high", and only handle the first line with such fields. Note that because the separator will follow each value, NF will be one more than the number of temperatures.
Wow, that is amazing. Thank you for explaining all of that to me.
|All times are GMT -5. The time now is 11:26 AM.|