I'm running a command from within terminal that goes through a directory checking for media files and then extracts closed captioning data from those files. Unfortunately, even if there is no closed captioning data present, the program still processes the entire file and this can take a long time. What I would like to be able to do is check the output after 60 seconds and look for data, and if the file is empty, terminate the process and move on to the next file.
My old command is as follows
for i in */*.vob
do
/home/me/ccextractor/linux/ccextractor -out=srt -utf8 -trim "$i"
done
I've been experimenting with sleep
but I can't seem to get it working. Any suggestions?
SOLUTION
With help from the answers below (take note of the comments as well), my final working code is:
for i in */*.vob
do
/home/me/ccextractor/linux/ccextractor -out=srt -utf8 -trim "$i" &
pid=$!
sleep 15
srtfile=$(expr "${i}" | sed -r 's/.{4}$//')
fgrep -q "1" "${srtfile}.srt" || kill $pid
wait $pid
done