g | x | w | all
Bytes Lang Time Link
002Jalapeño250306T212226ZATaco
093Tcl180602T151114Zsergiol
052Ruby140127T180324Zdaniero
003Japt210806T115639ZShaggy
006Vyxal210805T100637Zemanresu
021Burlesque181125T133417Zmroman
033K4181125T112348Zmkst
007Retina180426T204200Zmbomb007
nan140122T191738ZFireFly
043PowerShell 43140127T162317Zmicrobia
092Brainfuck140126T005344ZSylweste
388iX3140123T171258ZTimtech
nan140122T192232ZOberon
nan140122T184348Zamon

Jalapeño, 2 bytes

∩¢₁

Also ignores file IO requirements.

Simply takes the intersect of the input and all printable ascii ¢₁ and implicitly returns.

Hex-Dump of Bytecode

       0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
0000: ef 28                                           

Try it Online!

Tcl, 93 bytes

puts -nonewline [set g [open b.txt w]] [regsub -all {[^ -~]} [read [open a.txt]] ""]
close $g

Try it online!

Ruby (52)

Challenge #1

 IO.write (f="a.txt"),IO.read(f).gsub(/\p{Cntrl}/,'')

Japt, 3 bytes

Well, seeing as everyone else is ignoring the requirements to read from & write to a file ...

Input also from this SO answer.

;oE

Try it

Japt v2.0a0, 3 bytes

r\P

Try it

Vyxal, 6 bytes

kPs5ȯ↔

Try it Online!

Fixed thanks to Aaron Miller. Why does the printable ascii builtin contain unprintables?

Burlesque - 21 bytes

{**{31.>}{127.<}m&}f[

This can be shortened be replacing the 128 with '<DEL> (where DEL is the delete character) but I'm not sure how I can post a DEL here (also replace the 31 and then you can also get rid of the **)).

Also, in the WIP version you can golf this down to :un:ln.

K4, 36 33 bytes

Solution:

`b.txt 1:{x@&31<x*127>x}@1:`a.txt

Explanation:

Above is for Challenge A, replace the b.txt for a.txt for Challenge B.

`b.txt 1:{x@&31<x*127>x}@1:`a.txt / the solution
                         1:`a.txt / binary read (1:) "a.txt"
                        @         / apply to 
         {             }          / lambda taking 1 implicit arg (x)
                  127>x           / 127 greater than?
                 *                / multiply by
                x                 / x
             31<                  / 31 less than?
            &                     / indices where true
          x@                      / index into x at these indices
`b.txt 1:                         / binary write to "b.txt"

Retina, 7 bytes

Simple regex to remove non-printable ASCII.

[^ -~]

Try it online!

Test input copied from this SO post.

sh

Challenge 1, 24 23 chars

tr -dc \ -~<a.txt>b.txt
Bonus: variations on the set of characters to delete.
tr -dc " -~
"<a.txt>b.txt                       # preserves printables + line feed

tr -dc "[:space:] -~"<a.txt>b.txt   # preserves printables + whitespace

PowerShell (43, 43)

Challenge 1: (43)

(gc -raw a.txt) -replace"[^ -x7e]","">b.txt

Challenge 2: (43)

(gc -raw a.txt) -replace"[^ -x7e]","">a.txt

Brainfuck: 92

+[[->+>+<<]>>>++++++++[->++++++++++++<<---->]>--[<<[->]>[<]>-]<+<[[-]>-<]>[[-]<<.>>]<<[-]<,]

Brainfuck cannot open files so you use stdin/stdout redirection (#1)

bf strip.bf < a.txt > b.txt

The same code in Extended Brainfuck: 68

+[(->+>+)3>8+(->12+<<4-)>2-[<<[->]>[<]>-]<+<([-]>-)>([-]2<.)2<[-]<,]

iX3, 388

Set  in [c]:  '1'
Loop start   ([c]  of 1  to 999999999)
   Read from file  'a.txt' into [T] (read from [c], 1 bytes)
   Modify text  '[T]' into [R] (code in Hex)
   Set  in [N]:  '&H[R]' (calculate)
   If  True: '([N]=10)'
      Write into file  'b.txt' line '' (Append)
   End If
   If  True: '([N]>31)&([N]<127)'
      Write into file  'b.txt' line '[T]' (Append, no linefeed)
   End If
Loop end

Both are Challenge 1.

C - 132 characters

#include<stdio.h>
k;main(){FILE*f=fopen("a.txt","rb");FILE*g=fopen("b.txt","w");while(!feof(f))(k=getc(f))>31&&k<127&&putc(k,g);}

Python - 78 characters

file("b.txt","w").write(filter(lambda x:'~'>=x>' ',file("a.txt").read()))

Bash + Perl

Challenge 1 – 31 bytes

perl -petr/\ -~//cd a.txt>b.txt

Challenge 2 – 28 bytes

perl -i -petr/\ -~//cd a.txt