You can generate a noise profile for SoX with:
sox sample-input.wav --null noiseprof ~/noise.profile
You can then use the profile to filter your recording:
sox recording.wav filtered.wav noisered ~/noise.profile
This works because static noise that your microphone picks up usually depends on your setup (wiring) and is thus always about the same in the same environment. Note that SoX is considerably worse than Audacity at removing noise. :(
Additionally, you could use ffmpeg's audio filters like highpass/lowpass to diminish frequencies below/above certain threshold, or use compand filter to compress dynamic range of the recording and/or make a noise gate.
Once you have the noise profile, the complete process pipeline could be:
ffmpeg -f alsa -i hw:0,0 -af 'highpass=300, lowpass=4000' -f wav - | sox -f wav -f wav - noisered ~/noise.profile | aplay
Note, you should extract the profile from the ffmpeg-filtered recording, if you use those filters.