I like GNU parallel
, but I find performing string replacements rather complex.
I'm used to simple manipulation such as done in Bash:
$ f="encodes/TearsOfSteel-720-crf41.mp4"
$ echo "$(basename "${f%%-*}")"
TearsOfSteel
Basically, I want to find the basename (everything before the first minus-hyphen) of each input file. With parallel
, I'd then want to perform a command with the original filename and the basename:
parallel './do_something {} <basename>' ::: encodes/*.mp4
… where <basename>
is what Bash would do if you gave it basename "${f%%-*}"
, and f
obviously being {}
.
The non-parallel version would be:
for f in encodes/*.mp4; do
bn="$(basename "${f%%-*}")"
./do_something "$f" "$bn"
done
How can I do that with parallel
?