Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in the process of making a bash script to scrape a to get the weather report. I need to process a line of text that has an unusual character. Here is the text:

30°FHigh 35°High 52°High 45°High 43°High

There is a small circle between the numbers and the letters. Here is the code:



lynx --dump | \
egrep '   Today |   Tonight ' -A 22 | awk 'BEGIN {print "\n\t\t\b\b\b\b\b\bTHE FIVE DAY\
/[0-9][0-9]*[a-z|A-Z]+/{print $1"\t\t"$2" "$3"\t\t"$4" "$5"\n"}' 2>> error.txt

This gives no output.

share|improve this question
The "small circle" is a degree symbol. – user3463 Jan 21 '12 at 21:31
How do I awk that? – userend Jan 21 '12 at 21:42
Looks like an awk-ward question. – Mehrdad Jan 21 '12 at 23:35
up vote 1 down vote accepted

The easiest way is to use a dot to match the degree symbol.


For example

$ echo -e "30\0260FHigh" \
| awk '/[0-9][0-9]*.[a-z|A-Z]+/ { print "yes" }'


(\0260 is octal for the degree symbol in your question)

If you want to match it exactly you'd have to identify it's value in the encoding used. In the text in your question it seems to be 0xb0.

 $ echo -e "30\0260FHigh" \
 | awk '/[0-9][0-9]*\xb0[a-z|A-Z]+/ {print "yes" }'


\0260 and \xb0 just illustrate two ways to indicate the same thing.

share|improve this answer
Yes, this is what I needed. I guess my regex was off a bit. – userend Jan 21 '12 at 22:26

Modern Linux shell is very Unicode-aware. In fact, I think all the data are treated as UTF-8.

I had no problem running this code:

$ echo ° | awk '/°/{print "found it"}'
found it

If you're making a shell script, make sure you have it in UTF-8 instead of ASCII.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .