1GMT_SHELL_FUNCTIONS.SH(1)    Generic Mapping Tools   GMT_SHELL_FUNCTIONS.SH(1)
2
3
4

NAME

6       gmt_shell_functions.sh  -  Practical functions to be used in GMT bourne
7       shell scripts
8

SYNOPSIS

10       gmt_init_tmpdir
11       gmt_remove_tmpdir
12       gmt_clean_up
13       gmt_message message
14       gmt_abort message
15       gmt_nrecords file(s)
16       gmt_nfields string
17       gmt_get_field string
18       gmt_get_region file(s) [options]
19       gmt_get_gridregion file [options]
20       gmt_get_map_width -R -J br gmt_get_map_height -R -J
21       gmt_set_psfile file
22

DESCRIPTION

24       gmt_shell_functions.sh provides a set of functions  to  bourne  (again)
25       shell  scripts  in  support  of  GMT.   The calling shell script should
26       include the following line, before the functions can be used:
27       . gmt_shell_functions.sh
28       Once included in a  shell  script,  gmt_shell_functions.sh  allows  GMT
29       users  to  do  some scripting more easily than otherwise. The functions
30       made available are:
31
32       gmt_init_tmpdir
33              Creates a temporary directory in /tmp or (when defined)  in  the
34              directory specified by the environment variable TMPDIR. The name
35              of the temporary directory is returned as  environment  variable
36              GMT_TMPDIR.  This  function also causes GMT to run in `isolation
37              mode', i.e. all temporary files will be  created  in  GMT_TMPDIR
38              and the .gmtdefaults file will not be adjusted.
39
40       gmt_remove_tmpdir
41              Removes  the temporary directory and unsets the GMT_TMPDIR envi‐
42              ronment variable.
43
44       gmt_cleanup
45              Remove all files and directories in which  the  current  process
46              number is part of the file name.
47
48       gmt_message
49              Send a message to standard error.
50
51       gmt_abort
52              Send a message to standard error and exit the shell.
53
54       gmt_nrecords
55              Returns the total number of lines in file(s)
56
57       gmt_nfields
58              Returns the number of fields or words in string
59
60       gmt_get_field
61              Returns  the  given  field in a string. Must pass string between
62              double quotes to preserve it as one item.
63
64       gmt_get_region
65              Returns the region in the form w/e/s/n based on the data in  ta‐
66              ble file(s). Optionally add -Idx/dy to round off the answer.
67
68       gmt_get_gridregion
69              Returns  the region in the form w/e/s/n based on the header of a
70              grid file. Optionally add -Idx/dy to round off the answer.
71
72       gmt_map_width
73              Expects the user to give the desired -R -J settings and  returns
74              the map width in the current measurement unit.
75
76       gmt_map_height
77              Expects  the user to give the desired -R -J settings and returns
78              the map height in the current measurement unit.
79
80       gmt_set_psfile
81              Create the output PS file name based on the base name of a given
82              file (usually the script name $0).
83

NOTES

85       1. These functions only work in the bourne shell (sh) and their deriva‐
86       tives (like ash, bash, ksh and zsh).  These functions do  not  work  in
87       the  C shell (csh) or their derivarives (like tcsh), and cannot be used
88       in DOS batch scripts either.
89       2. gmt_shell_functions.sh were first introduced in  GMT  version  4.2.2
90       and  have  since been regularly expanded with other practical scripting
91       short-cuts. If you want to suggest other functions,  please  do  so  by
92       mailing to the GMT mailing list: gmt-help@hawaii.edu.
93

SEE ALSO

95       GMT(1), sh(1), bash(1), minmax(1), grdinfo(1)
96
97
98
99GMT 4.2.2b                        1 Apr 2008         GMT_SHELL_FUNCTIONS.SH(1)
Impressum