GNU Astronomy Utilities

Next: , Previous: , Up: Command-line   [Contents][Index]

4.1.1 Arguments and options

On the command-line, the first thing you usually enter is the name of the program you want to run. After that, you can specify two types of input: arguments and options. In the GNU-style, arguments are those tokens that are not preceded by any hyphens (-, see Arguments). Here is one example:

$ astcrop --center=53.162551,-27.789676 -w10 --mode=wcs hubble-udf.fits

In this example, the argument is hubble-udf.fits. Arguments are most commonly the input file names containing your data. Options start with one or two hyphens, followed by an identifier for the option (the option’s name) and its value (see Options). Through options you tell the program how to interpret the data. In this example, we are running Crop to crop a region of width 10 arc-seconds centered at the given RA and Dec from the input Hubble Ultra-Deep Field (UDF) FITS image. So options come with an identifier (the option name which is separate from their value).

Arguments can be both mandatory and optional and unlike options they don’t have any identifiers (or help from you). Hence, their order might also matter (for example in cp which is used for copying one file to another location). The outputs of --usage and --help shows which arguments are optional and which are mandatory, see --usage. As their name suggests, options on the command-line can be considered to be optional and most of the time, you don’t have to worry about what order you specify them in. When the order does matter, or the option can be invoked multiple times, it is explicitly mentioned in the “Invoking ProgramName” section of each program.

In case your arguments or option values contain any of the shell’s meta-characters, you have to quote them. If there is only one such character, you can use a backslash (\) before it. If there are multiple, it might be easier to simply put your whole argument or option value inside of double quotes ("). In such cases, everything inside the double quotes will be seen as one token or word.

For example, let’s say you want to specify the header data unit (HDU) of your FITS file using a complex expression like ‘3; images(exposure > 100)’. If you simply add these after the --hdu (-h) option, the programs in Gnuastro will read the value to the HDU option as ‘3’ and run. Then, Bash will attempt to run a separate command ‘images(exposure > 100)’ and complain about a syntax error. This is because the semicolon (;) is an ‘end of command’ character in the shell. To solve this problem you can simply put double quotes around the whole string you want to pass to --hdu as seen below:

$ astcrop --hdu="3; images(exposure > 100)" FITSimage.fits

Alternatively you can put a ‘\’ before every metacharacter in this string, but try doing that, and probably you will agree that the double quotes are much more easier, elegant and readable.

Next: , Previous: , Up: Command-line   [Contents][Index]