rtl-sdr is a commandline tool that can initialize the RTL2832, tune to a given frequency, and record the I/Q-samples to a file.
The code can be checked out with:
git clone git://git.osmocom.org/rtl-sdr.git
via rtl-sdr – OsmoSDR.
Software Defined Radio