I am trying to remove unseen junk characters from the file which can be seen using cat -v . I got the script below in google but i am curious to know how the below command works .

tr -cd '\11\12\40-\176' < Actual_file.txt > Actual_clean.txt

Thank you.

1 Answer 1


It's an obtuse way of writing tr -cd '\t\n -~' ...

-c means complement, -d means delete. That will delete all characters but tab, newline and the ASCII printable characters (starting with space and ending with tilde). See man ascii(7).

It will also delete printable utf-8 characters, which are used a lot on modern Unix system, so it's a bit over-the-top.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .