I got a file that looks like this:
<text top="123" left="45" width="50" height="17" font="8">Måndag</text>
As noted in the topic, this file is encoded in utf-8. When using this command:
cat file | sed 's_.*top="\([0-9][0-9]*\)" left="\([0-9][0-9]*\)".*>\(.*\)<.*_\1 \2 \3_'
it never completes the execution and prints nothing.
However executing a line like this one:
cat file | sed 's/å/FOO/'
gives me a correct output:
<text top="123" left="45" width="50" height="17" font="8">MFOOndag</text>
Is this a bug in sed or is there something wrong with my regex or the way that I'm using it? What I want is a neat way to extract the top, left and content data without involving too many commands.
sed
doesn't complete on that command, regardless of the input, it looks like a bug. What OS are you running (name, distribution, version)? Do you have the same effect if you run<file sed …
? What locale are you in? Are you absolutely sure the input is in UTF-8 (post the output ofhd file
orod -t x1 file
)? – Gilles 'SO- stop being evil' Apr 18 '11 at 22:23echo $LANG
givessv_SE.UTF-8
. I'll probably have to learn another language such as perl suggested by tchrist further down. Till then, I'll work around the problem with an ugly solution. – Shump Apr 18 '11 at 23:07od -t x1 file
:0000000 3c 74 65 78 74 20 74 6f 70 3d 22 31 32 33 22 20 0000020 6c 65 66 74 3d 22 34 35 22 20 77 69 64 74 68 3d 0000040 22 35 30 22 20 68 65 69 67 68 74 3d 22 31 37 22 0000060 20 66 6f 6e 74 3d 22 38 22 3e 4d c3 a5 6e 64 61 0000100 67 3c 2f 74 65 78 74 3e 0a 0000111
– Shump Apr 18 '11 at 23:07c3 a5
⇒ ok, the input is UTF-8. This does look like a bug in OSX's sed. – Gilles 'SO- stop being evil' Apr 18 '11 at 23:10