m.cutmatrix 570 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. # m.cutmatrix: this script allows to cut out matrix fields
  3. # written by Markus Neteler 21.July 1998
  4. # neteler@geog.uni-hannover.de
  5. if [ $# -ne 3 ] ; then
  6. echo
  7. echo "This tool displays a field out of a ASCII Matrix."
  8. echo "USAGE: m.cutmatrix file xpos ypos"
  9. echo
  10. exit 1
  11. fi
  12. if [ ! -f "$1" ] ; then
  13. echo "$0: file [$1] not found"
  14. exit 1
  15. fi
  16. if [ $2 -lt 1 ] || [ $3 -lt 1 ] ; then
  17. echo "xpos ($2) and ypos ($3) must be positive integers"
  18. exit 1
  19. fi
  20. cat "$1" | tail -n 7 | cut -f $2 -d ' ' | head -n $3 | tail -n 1