Bash substitute gives unexpected results (?)
Nils Kassube
kassube at gmx.net
Sun Apr 5 09:16:16 UTC 2015
Johnny Rosenberg wrote:
> This is what I want. Everything except ”(” and ”–” (n-dash) should be
> removed.
> However, using pure Bash doesn't seem to work:
>
> $ a="Black Sand Beach (ブラック・サンド・ビーチ)"; echo ${a//[^(|–]}
> (ブラック・サンド・ビーチ
> $
> Why does Bash consider n-dash and some Japanese characters the same?
Maybe the three character encoding of your n-dash and the Japanese
characters look similar enough to bash?
> Is there a setting I need to do somehow?
It has something to do with your locale settings. If you try the same
with the default locale, the result is different. So I think you should
set one of the LC_* shell variables (probably LC_COLLATE) to Japanese
and try your command again.
Nils
More information about the ubuntu-users
mailing list