Strip all non-printable ASCII characters Your challenge, should you be coded to accept it, runs as follows:

You may choose one of the following two challenges to implement:

Challenge #1


Read from a file a.txt
Write only printable ASCII characters (values 32-126) to a file b.txt


Challenge #2


With a file a.txt, delete all characters in the file except printable ASCII characters (values 32-126)


Specs on a.txt

a.txt is a plain text file which can include any ASCII values from 0-255 (even undefined/control) and its size can range up to 1 GB.

Winning

The answer with the smallest amount of sourcecode in bytes wins.
sh



Challenge 1, 24 23 chars

tr -dc \ -~&lt;a.txt&gt;b.txt


Bonus: variations on the set of characters to delete.

tr -dc " -~
"&lt;a.txt&gt;b.txt                       # preserves printables + line feed




tr -dc "[:space:] -~"&lt;a.txt&gt;b.txt   # preserves printables + whitespace