Skip to content
Advertisement

Linux cat and less output for my text file is different from gedit and other gnome editor

I redirected ri’s ruby Array doc into a file but it didn’t look good in gedit. But text looks just fine in cli. That’s how my file looks in terminal editors. Everything is fine here.

JavaScript

But when I open it in gedit or other gnome editors, that’s how it looks like. Some specific words look in absurd format. Any suggestions or help will be appreciated.

JavaScript
I tried opening it into every system. but text is still messed up everywhere except terminal editors like cat or less. Does it have anything to do with text encoding?

Advertisement

Answer

ri outputs documentation formatted as ASCII text, with overstriking. You can check this by running the file command on your file.

Some parts of the documentation are bolded, which is represented by some character, backspace (^H) and the first character again. It seems that gedit and other gnome editors ignore these backspace characters, leaving the actual character repeated.

You can output just the ASCII like this: ri Array | col -bx > array.txt

An answer with more information about nroff formatting: https://unix.stackexchange.com/a/274795

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement