Using gmtinfo variables as other command inputs


I want to combine two commands to hopefully pass the -R extents output from gmtinfo to the next command xyz2grd. I’ve read that if you leave the -R empty then it takes the last -R extents but I don’t think it’s taking it from the output of GMT Info. Here is my cmd command:

for %f in (*.xyz) do gmt info -I1 “%f” & xyz2grd -R -I1 -G"%~nf_singleband.tif"

Is there a way of exporting the gmtinfo outputs as variables? or am I doing something wrong?


One possible way using bash:

for FILE in *.xyz
xyz2grid $(gmtinfo -I1 $FILE) -I1 -G"${}nf.tif"