I have a small shellscript in .x
$ cat .x
u="B?hmáí"
touch "$u"
ls > .list
echo "$u" >.text
cat .list .text
diff .list .text
od -bc .list
od -bc .text
When i run this scrpit sh -x .x
(-x only for showing commands)
$ sh -x .x
+ u=B?hmáí
+ touch B?hmáí
+ ls
+ echo B?hmáí
+ cat .list .text
B?hmáí
B?hmáí
+ diff .list .text
1c1
< B?hmáí
---
> B?hmáí
+ od -bc .list
0000000 102 157 314 210 150 155 141 314 201 151 314 201 012
B o ? ** h m a ? ** i ? **
0000015
+ od -bc .text
0000000 102 303 266 150 155 303 241 303 255 012
B ? ** h m á ** í **
0000012
The same string B?hmáí
has encoded into different bytes in the filename vs as a content of a file. In the terminal (utf8-encoded) the string looks same
in both variants.
Where is the rabbit?
See Question&Answers more detail:os