Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • I understand what tr command does. I understand (more or less) what LC_ALL = C is, but not all together. Nevertheless tr -d removes those characters, but I want to replace with spaces. Sorry, title was wrong. I just realized, when @don_crissti modified. Commented May 6, 2015 at 11:33
  • @Albert, sorry. See the edit and the link I added. Commented May 6, 2015 at 11:36
  • I not sure sure about encoding. That file comes from a HOST environment, which uses EBCDIC encoding, and it is transferred to Linux using XCOM. For instance, non ASCII-characters like É are codified (using od -xa) as 0xC9, so I guess it would be ISO-8859-1. Commented May 6, 2015 at 12:05
  • @Albert, probably. You can use locale -a to see if there are locales with iso8859-1 as the charset on your system and use LC_CTYPE=<that-locale> tr ...[:print:]... to convert non-printables in that locale. Or you can use iconv to convert those files to your locale's charset. Commented May 6, 2015 at 12:20
  • I think it's not needed, because my locale's charset is set to LC_ALL=en_US.iso88591. So, your command (tr -c '[:print:]\t\r\n' '[ *]') works perfectly without modifying locale or converting file. Thanks a lot. Commented May 6, 2015 at 12:29