2

I do a

cd /folder/ && find . -not \( -path ./exclude_folder -prune \) > /log.log

and get

find: â<80><98>./qs/www/ergebnisse/validitaet/0df21b8a-e227-47b2-aaa5-9f54d1f9b8fd.txtâ<80><99>: No such file or directory

inside log file. That is right, but:

What is this â<80><98> (and â<80><99>)? Are these color codes? How to avoid them (find does not have --no-color)?


Hold on. When I do cat log.log instead of vi log.log I get:

find: ‘./qs/www/ergebnisse/validitaet/0df21b8a-e227-47b2-aaa5-9f54d1f9b8fd.txt’: No such file or directory
2
  • 3
    Fix your vi to use the utf-8 encoding instead of iso-8859-junk. Or use LC_MESSAGES=en_US.UTF-8@noquot find ... which will direct find to use plain ascii quotes instead of ‘...’ in its error messages.
    – user414777
    Feb 2, 2021 at 11:53
  • 3
    Yes, that would be the UTF-8 encoding of U+2018 (0xe2 0x80 0x98, \N{LEFT SINGLE QUOTATION MARK}) interpreted as iso8859-1 instead of UTF-8. Feb 2, 2021 at 12:24

2 Answers 2

8

Your distribution uses UTF-8 character encoding. This is normal for most current distributions.
What you see is the effect of UTF-8 coded characters displayed as another encoding.

Many GNU utilities try to use different quotation marks for opening and closing quotes. With some fonts this looks good, with others not so good.

Let's look at the output produced by find:

$ find /x 2>&1 | hexdump -C
00000000  66 69 6e 64 3a 20 e2 80  98 2f 78 e2 80 99 3a 20  |find: .../x...: |

Before and after the /x we have the sequences e2 80 98 and e2 80 99.

Your console is configured for UTF-8 and is able to display the UTF-8 sequence correctly. The cat program doesn't recognize or care about this sequence, so it doesn't matter.

On the other hand, your vi is interpreting the file as latin1. This is at least unusual on a modern distribution. In latin1, the first byte, e2, is interpreted as â while 80, 98 and 99 are invalid in latin1 and displayed as <80> and so on. This results in â<80><98> and â<80><99>.

How to avoid that? You can configure your vi to display files as UTF-8, or you can avoid the UTF-8 sequences in your output.

$ LC_CTYPE=C find /x 2>&1 | hexdump -C
00000000  66 69 6e 64 3a 20 27 2f  78 27 3a 20   |find: '/x': |

Here find doesn't generate UTF-8 sequences and instead uses the single quote ' for opening and closing quote.

Note that disabling UTF8 might change how programs process their input, although it shouldn't matter in your example.

1
  • Thanks, dude! In your .vimrc, add set encoding=utf-8 and restart Vim.
    – uav
    Feb 2, 2021 at 20:21
1

this is a codes on start and on end.

â<80><98> = ‘
â<80><99> = ’

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.