Now for the coolest of all of the little tricks. We will create a streaming mp3 server that streams a live audio capture over the network. This is a task that entire software packages are devoted to, but we are going to create one in a one-liner bash command thanks to the flexibility of a Unix-like environment.

Before we piped our output from rec to lame and had lame save it to disk. This time we will use our little netcat trick from he very first PCLug meeting. Instead of having lame save its output to disk we tell it to put it's output to standard out with another "-" and then pipe it once again to netcat. On the client machine we have netcat listening for input and pipe its output directly to mpg123 (a command line mp3 player). Viola, we have streaming mp3 encoded sounds in one bash command. (Note: the example is streaming over the loopback interface on a single machine just to show how it is done. You can stream over the actual wire to another machine by just changing the machine name.

on recording machine: rec -c 2 -r 44100 -t wav -s w - | lame -h -b128  - - | nc localhost 9999
on playing machine: nc -l -p 9999 | mpg123 -