On Wed, Oct 17, 2012 at 2:56 PM, <giuseppe.amatu...@gmail.com> wrote: > so this is my actual gol: > > change this loop ( which is working fine ) > > for file in /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tiff/*.tif > ; do > filename=`basename $file .tif` > tile=${filename:3:6} > echo processin $file > oft-stat $file > /weldgfs/p51/gius_urban/LandCover/tree_cover/TREE_COVER_$tile.tif > /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tree/UA_tree$tile.txt > oft-stat $file > /weldgfs/p51/gius_urban/LandCover/bare_ground/BARE_GROUND_$tile.tif > /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_bare/UA_bare$tile.txt > done > > in > > ls /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tiff/*.tif | xargs > -n 1 -P 10 bash -c ' > file="$1" > filename=`basename $file .tif` > tile=${filename:3:6} > echo processin $file > oft-stat $file > /weldgfs/p51/gius_urban/LandCover/tree_cover/TREE_COVER_$tile.tif > /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tree/UA_tree$tile.txt > oft-stat $file > /weldgfs/p51/gius_urban/LandCover/bare_ground/BARE_GROUND_$tile.tif > /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_bare/UA_bare$tile.txt > ' _ > > > for multi process in parallel, without call an external script. . of course > the echo $1 was a way to simplify the full task. Now the script works fine > Thanks to all you > Ciao > Giuseppe > >
You're still lacking quotes. "$file", never $file. And you have the same issue with ls. printf '%s\0' /weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tiff/*.tif | xargs -0 -n 1 -P 10 bash -c ' file="$1" filename=${file##*/} filename=${filename%.tif} tile=${filename:3:6} echo "processing $file" oft-stat "$file" "/weldgfs/p51/gius_urban/LandCover/tree_cover/TREE_COVER_$tile.tif" "/weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_tree/UA_tree$tile.txt" oft-stat "$file" "/weldgfs/p51/gius_urban/LandCover/bare_ground/BARE_GROUND_$tile.tif" "/weldgfs/p51/gius_urban/pop_urban/tl_2010_us_uac10/UA_bare/UA_bare$tile.txt" ' _ would be one option... or do the parallel processing in bash itself... see http://mywiki.wooledge.org/ProcessManagement and https://github.com/e36freak/templates/blob/master/threads or https://github.com/e36freak/templates/blob/master/parallel