I have the following case:
I would like to browse files in a directory $1until one of them fulfills my condition.
In detail: I would like to test the catalog about whether it contains audio files. As soon as the first audio file is found, it process_audio_dirshould take place; if there are no audio files in the directory, it process_noaudiowill happen.
My decision:
if [[ -z $(file -b "$1"/* | grep -i audio) ]]; then
echo "there are no audio files"; process_noaudio
else
echo "at least one audio file"; process_audio_dir
fi
file -b tells me which file is the file.
My guess, looking at it with help set -x, is that it will run file -bin all files, put the result on one line and fit that line to match. (Perhaps this is a wrong assumption).
, , ( , ), / , , , process_noaudio.
, / , , .
( ) ?