There's a huge colection of examples on soxexam(1) - zcat

Under linux, you can record just by catting from /dev/dsp or /dev/audio. These 2 devices behave in almost exactly the same way - the only difference is that by default /dev/audio uses m-law format while /dev/dsp uses 8 bit unsigned data by default. You can change these settings by using the ioctl(2) function.

I use sox for converting between formats. Eg to play a raw file to the audio device
sox -t ub sound.raw -t ossdsp /dev/dsp

The type "ub" is shorthand for unsigned bytes (8 bit samples). s means signed, and w means words (16 bit samples).

Here's how you might do a fade out
sox -t wav sound.wav -e fade 0 0 3 -t ossdsp /dev/dsp

This will take your file named sound.wav, and do the effect named fade on it. The first 0 means no fade-in, the second 0 means stop the fade-out 0 seconds before the end, and the 3 means start the fade-out 3 seconds from the end. This gets output to the sound device.

Note - the above command has not been tested! So if it's wrong, please edit this page to correct it.