Answer the question
In order to leave comments, you need to log in
Bash script: how to insert an external variable into a compound command?
There is the following script:
#!/bin/bash
find ./ -type f -name '*.png' | xargs -P 8 -I {} sh -c 'cwebp -q 75 $1 -o "${1%.png}.webp"' _ {} \;
#!/bin/bash
quality=${1:-75}
find ./ -type f -name '*.png' | xargs -P 8 -I {} sh -c 'cwebp -q $quality $1 -o "${1%.png}.webp"' _ {} \;
' ^^^^^^^^ '
Answer the question
In order to leave comments, you need to log in
I apologize for answering myself, but after suffering for another hour, thanks to the Internet, I nevertheless solved the problem - maybe not too elegant, but the main thing that works:
#!/bin/bash
quality=${1:-75}
part1='cwebp -q '
part2=' $1 -o "${1%.png}.webp"'
cmd=$part1$quality$part2
find ./ -type f -name '*.png' | xargs -P 8 -I {} sh -c "$cmd" _ {} \;
$ webp-convert # качество 75
$ webp-convert 90 # качество 90
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question