Reputation: 446
I am running gdalinfo
command in parallel to obtain statistics from *.tif
files
find *tif -printf "%f\n" | parallel -j 5 "/usr/local/bin/gdalinfo -mm -stats -hist -json {} > {}.json"
{}
will be replaced by file being processed e,g. SRTM.tif
, therefore output file named: SRTM.tif.json
How to do string subtitution on {}
?
Using loops in Bash, I normally do ${f%.tif}.json
but it does not work (we do not have a bash variable) and also tried awk
but no success.
Upvotes: 3
Views: 930
Reputation: 20002
You can find tif files woth something like
find . -name "*.tif" -print | cut -d "." -f1 |
parallel -j 5 "/usr/local/bin/gdalinfo -mm -stats -hist -json {}.tif > {}.json"
Edit: Or, with the suggestion in the other respose:
find . -name "*.tif" -print |
parallel -j 5 "/usr/local/bin/gdalinfo -mm -stats -hist -json {.}.tif > {.}.json"
Upvotes: 0
Reputation: 4969
In parallel
, {.}
is the input-line without extension. So use that instead of {}
. If you really want to do complicated string manipulation, use {= perl expression=}
.
Upvotes: 3