[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to parallelize find|while read do; ffprobe, grep and get the fil
From: |
Ole Tange |
Subject: |
Re: How to parallelize find|while read do; ffprobe, grep and get the filenames? |
Date: |
Sat, 12 Nov 2022 16:53:25 +0100 |
On Sat, Nov 12, 2022 at 2:55 PM D <dcmhoybdpzkh@web.de> wrote:
>
> Hello,
>
> I'm trying to parallelize my Bash shell script:
>
> find . -type f -iname "*.flac" -print0 | while read -d $'\0' FILENAME; do
> INFOS=$(ffprobe -hide_banner "$FILENAME" 2>&1)
> URL=$("$INFOS"|& grep -i 'http\|www')
> if [ "$URL" != "" ]; then
> echo -e "$FILENAME\t$URL"
> fi
> done | column -t -s $'\t'
doit() {
FILENAME="$1"
INFOS=$(ffprobe -hide_banner "$FILENAME" 2>&1)
URL=$("$INFOS"|& grep -i 'http\|www')
if [ "$URL" != "" ]; then
echo -e "$FILENAME\t$URL"
fi
}
export -f doit
find . -type f -iname "*.flac" -print0 | parallel doit |
column -t -s $'\t'
I think you have misunderstood how GNU Parallel works.
You should spend 20 minutes reading chapter 1+2:
https://doi.org/10.5281/zenodo.1146014 (Print:
https://www.lulu.com/shop/ole-tange/gnu-parallel-2018/paperback/product-23558902.html)
/Ole