idclark
idclark

Reputation: 958

How can I see which characters have been removed from file after running tr -cd

To remove any non-ascii characters from a file, I tried

tr -cd '\11\12\15\40-\176' < original.csv > clean-copy.csv

I'd like to see the specific characters that were removed from the file, is there any way to print them out? The only thing I can think of is

diff original.csv clean-copy.csv but I don't think that is sufficient.

Upvotes: 0

Views: 21

Answers (1)

rici
rici

Reputation: 241881

tr -d '\11\12\15\40-\176' < original.csv

will give you all the characters you deleted (same as your original, but without the complement (-c).

I suppose you probably wanted them printed out in some more readable format, though; you could try piping that through hd.

If you need byte offsets, that's a different question.

Upvotes: 1

Related Questions