0

im trying the following sed command, but i have no luck with special chars:

echo "x#asdf" | sed "s/\([^-]\)#/\1\n/g"

x
asdf

but if i use some special char in test.txt

echo "ä#asdf" | sed "s/\([^-]\)#/\1\n/g"

ä#asdf

why ?

this works:

echo "ü#asdf" | sed "s/ü/-/g"
-#asdf

but this doesnt:

echo "ü#asdf" | sed "s/[ü]/-/g"
ü#asdf
Eric
  • 95,302
  • 53
  • 242
  • 374
gert
  • 75
  • 1
  • 6

1 Answers1

0

I'm not sure about this, because your sed commands work ok for me (gnu sed 4.1.5), but try invoking sed this way:

$ LANG=de_DE.UTF-8 sed ...

See this post for more information: Why does sed fail with International characters and how to fix?.

If this doesn't work, it may help to upgrade to gnu sed 4.2, if you can. The NEWS file says "multibyte processing fixed" for 4.2 but does not go into further detail.

Community
  • 1
  • 1
Tom Zych
  • 13,329
  • 9
  • 36
  • 53