Skip to main content

Raymii.org Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Strip all non-ascii characters from a file

Published: 27-06-2013 | Author: Remy van Elst | Text only version of this article


Table of Contents


If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

This snippet strips all non-ascii characters from a file. It backs up theoriginal file. This is handy if you have input for programs that bork on non-ascii input like older mainframes and such.

perl -i.bk -pe 's/[^[:ascii:]]//g;' filename
Tags: ascii, perl, snippets, utf-8