... sox -V $file -t raw /dev/null ...This command will issue an error message, if sox cannot parse the sound file format (which must be known to sox! Check the man page!). The option -V will cause sox to print out information about the contents, such as
sox: Detected file format type: wav sox: Chunk fmt sox: Chunk data sox: Reading Wave file: MS PCM format, 1 channel, 22050 samp/sec sox: 44100 byte/sec, 2 block align, 16 bits/samp, 190840 data bytes sox: Chunk LIST sox: Input file /usr/share/gallery/sounds/untie.wav: using sample rate 22050 size shorts, encoding signed (2's complement), 1 channel sox: Input file /usr/opt/office52/share/gallery/sounds/untie.wav: comment "1995-04-28You may pipe this output into a script to detect deviations from the expected parameters, for example:
... sox -V $file -T raw /dev/null | \ gawk -v FILE=$file '/Detected file/ { if($NF != "wav" ) \ { printf("ERROR: file %s is not a valid WAV format\n",\ FILE) } }' ...