Redo reformat to avoid DOS chars awk -f reformat.awk test_grid_Gslib.dat > points.dat Fix values that are not 1 thru 7, assign based on layer lagrit < points_fix.lgi cp outx3dgen points_fix.out Fixed set of points are points_fix.inp Read points.dat into avs and gmv format files lagrit < points.lgi awk '{ if ($4 > 0) print $4,$5,$6,$7 }' test_grid_Gslib.dat > points.dat