shellawksednon-ascii-characters

Remove non-ASCII characters from a file in place in Unix shell


I want to remove all the non-ASCII characters from a file in place.

I found one solution with tr, but I guess I need to write back that file after modification.

I need to do it in place with relatively good performance.


Solution

  • # -i (inplace)
    
    sed -i 's/[\d128-\d255]//g' FILENAME