[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A problem with regexes in sed
From: |
John Summerfield |
Subject: |
A problem with regexes in sed |
Date: |
Sat, 1 Feb 2003 07:52:44 +0800 (WST) |
Please, do not help spammers by archiving this with my email address in plain
view.
I'm running sed on debian (woody), and I want to convert a man page to plain
text by eliminating the <c>\b<c> sequences.
On my system, I do have a regex man page. On reading that, and the sed (man &
info) and awk documentation, i think this should work:
sed -e 's=\b.==g'
However, it does not, so I did a little exploration:
Nabarlek:~# echo -e 'a\ba' | sed -e 's=\b.==' | xxd
0000000: 0861 0a .a.
Nabarlek:~# echo -e 'a\ba' | sed -e 's=\b.==g' | xxd
0000000: 0a .
Nabarlek:~#
It seems to me that "\b" is not matching the backspace character as it ought.
This is from the AWK info document:
2. Data types, conversion and comparison
There are two basic data types, numeric and string.
Numeric constants can be integer like -2, decimal like
1.08, or in scientific notation like -1.1e4 or .28E-3.
All numbers are represented internally and all computa<AD>
tions are done in floating point arithmetic. So for exam<AD>
ple, the expression 0.2e2 == 20 is true and true is repre<AD>
sented as 1.0.
String constants are enclosed in double quotes.
"This is a string with a newline at the end.\n"
Strings can be continued across a line by escaping (\) the
newline. The following escape sequences are recognized.
\\ \
\" "
\a alert, ascii 7
\b backspace, ascii 8
\t tab, ascii 9
\n newline, ascii 10
\v vertical tab, ascii 11
\f formfeed, ascii 12
\r carriage return, ascii 13
\ddd 1, 2 or 3 octal digits for ascii ddd
\xhh 1 or 2 hex digits for ascii hh
The \xhh doesn't do anything either:
Nabarlek:~# echo -e 'a\ba' | sed -e 's=\x61.==' | xxd
0000000: 6108 610a a.a.
N
--
Cheers
John Summerfield
Microsoft's most solid OS: http://www.geocities.com/rcwoolley/
Note: mail delivered to me is deemed to be intended for me, for my disposition.
==============================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A problem with regexes in sed,
John Summerfield <=