Many utilities supplied with gsh take, as an argument, a filename or filenames. The shell utilities cat, ls, grep, and cp can take multiple filenames as arguments. If you wish to invoke any of these utilities on filenames that have a sequence of characters in common (ie. AND, APPLE, SHK, TXT, FILE2, FILE3, etc), gsh provides special characters, called regular expressions or wildcards, which match multiple filenames without having to enter all filename arguments manually.
Table 3-2. GSH Wildcard Operators
* | Matches any string of characters. |
? | Matches a single character. |
[abc] | Matches any of the characters enclosed in brackets. |
[^abc] | Matches any of the characters not enclosed in brackets. |
[a-c] | Matches the ascending sequence of characters enclosed in brackets. |
This method of matching filenames is known as "globbing". gsh performs globbing on the word prior to executing the command. The following gsh session illustrates file globbing:
[1]% cd /dev/gno/utilities [2]% ls :dev:gno:utilities CONV Crunch CrunchIIGS DeRez DiskCheck DumpObj Duplicate EMACS Equal Express Files LinkIIGS MakeBin MakeDirect OrcaDumpIIGS Prizm ResEqual Search canon choose clrff cmdfix coff compact count detab dir dirff dumpfile eject emacs.doc emacs.hlp emacs.rc emacs.tut help init join link macgen makelib mem online pageeject pause pwd src [3]% ls e* :dev:gno:utilities EMACS Equal Express eject emacs.doc emacs.hlp emacs.rc emacs.tut [4]% echo *r *m dir Prizm mem [5]% echo *i* cmdfix CrunchIIGS Prizm DiskCheck Duplicate Files init join LinkIIGS makelib MakeBin MakeDirect link dirff dumpfile online OrcaDumpIIGS dir [6]% echo NoMatch* No match. [7]% echo [a-f]* coff canon cmdfix compact Crunch CrunchIIGS DeRez DiskCheck DumpObj Duplicate EMACS emacs.doc emacs.hlp emacs.rc emacs.tut Equal Express Files choose clrff count detab CONV dirff dumpfile eject dir [8]% echo [a-fs-t]* coff canon cmdfix compact Crunch CrunchIIGS DeRez DiskCheck DumpObj Duplicate EMACS emacs.doc emacs.hlp emacs.rc emacs.tut Equal Express Files choose clrff count detab Search src CONV dirff dumpfile eject dir [9]% echo emacs?* EMACS emacs.doc emacs.hlp emacs.rc emacs.tut [10]% echo [^a-f]* Prizm help init join LinkIIGS makelib MakeBin MakeDirect link mem ResEqual Search src online pageeject pause OrcaDumpIIGS pwd macgen [11]% echo [^a-fs-t]* Prizm help init join LinkIIGS makelib MakeBin MakeDirect link mem ResEqual online pageeject pause OrcaDumpIIGS pwd macgen [12]% echo ??? mem src pwd dir [13]% echo ? No match. [14]% echo "???" ??? [15]% do you have a light? No match.
As can be seen by the above example, character matches are case insensitive. The ProDOS file system treats the filenames "file" and "FILE" as the same file. gsh recognizes this and does not detract from the underlying file system.
File globbing makes passing arguments to commands much easier and much more powerful. You could easily use "*.c" as an argument in a number of ways:
[1]% ls *.C lists all filenames ending in ".C" [2]% cc *.C compiles all files ending in ".C" [3]% more *.C displays contents of all files ending in ".C"