I want to change the frequency of an audio file. Meaning: the whole file should sound (say) one octave higher or lower. How to do it? Using ffmpeg or other command line open source tool would be preferable.

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.

Something like that:

sox <infile> <outfile> pitch <shift>

where gives the pitch shift as positive or negative ‘cents’ (i.e. 100ths of a semitone). There are 12 semitones to an octave, so that would mean ±1200 as a parameter.