2
votes

I have the following script that I want to run using GNU parallel, it is a for loop that needs to be run n times. How can I do this using GNU parallel?

SHARK=tshark

# Create file list
FILELIST=`ls $1`
TEMPDIR=/tmp/foobar
mkdir $TEMPDIR
i=1
for I in $FILELIST; do
    echo "$i $I $2"
    $SHARK -r $I -w $TEMPDIR/~$I-$i -R "$2" &>/dev/null
    i=`echo $i+1|bc`
done
1
Have you watched the intro videos? youtube.com/playlist?list=PL284C9FF2488BC6D1 - Ole Tange

1 Answers

1
votes

There are a number of ways of doing this, either with sub-shells and sub-processes, see e.g.

or by installing neat utilities designed to do this, e.g:

I would try to get it done first with sub-shells, and then try the others if you still need better power.