Amiga Computing - Commodore Is Awesome
Amiga Computing - Commodore Is Awesome
Amiga Computing - Commodore Is Awesome
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Neil Mohr explains<br />
how to use<br />
wildcards with<br />
the <strong>Amiga</strong>'s Shell<br />
Continuing my little delve into the<br />
<strong>Amiga</strong> Shell, I think it's about time<br />
we had a talk about wildcards. Even<br />
■^■M in their simplest form wildcards give<br />
a way of dealing with a large a number of files,<br />
in either manipulating selections of files or<br />
using wildcards to ignore other selections.<br />
A simple example would be to type into a<br />
Shell: dir #?, in return you will get a straight<br />
forward directory listing. Nothing stunning in<br />
that, but you have just unwittingly used a wild<br />
card, and probably one of the most commonly<br />
used ones. What you have actually told the<br />
Shell to do is give you a directory listing of<br />
everything in the current directory. It just so<br />
happens that typing dir will do the same thing,<br />
but that's beside the point.<br />
Wildcards allow you to tell the Shell to<br />
match all the filenames in a directory against a<br />
file pattern you have given it. This file pattern is<br />
made up partly of wildcards and partly of a<br />
normal filename. The simplest example<br />
expanding on the first one would be dir l#?.<br />
Here you have told the Shell to list every file<br />
that starts with I.<br />
The wildcard #? literally means anything<br />
and where the Shell encounters it, it will match<br />
anything to it. So if I were to ask you to find all<br />
the words beginning with C and ending in G<br />
you couid ask the computer the same with the<br />
You have more than likely come across the situation where<br />
you have typed a command or program name into the<br />
Shel! and it has returned with unknown command, but you<br />
know fulf well that it is on your hard drive. This happens<br />
because the <strong>Amiga</strong>'s operating system maintains a list of<br />
directories which it will search for commands when using<br />
either the Workbench or Shell.<br />
The standard search path is set up in the startup<br />
sequence and you can check what this is by typing PATH<br />
into a Shell and it will display a list of ail the directories<br />
that will be searched. If you want to add further directories<br />
you can either add them to the list in the startup sequence<br />
of you could add another path line in the user-startup, and<br />
at the end of list of extra directories put the command<br />
ADD. This tells the path command that you want to add<br />
these extra directories to the current list and to replace it.<br />
When using the she!! you can add extra directories at<br />
any time and the current Shell will use the new path list<br />
You should be aware only that Shell will use it and the<br />
Workbench search path will also stay unaffected. If you<br />
want to update the Workbench path list you need to type<br />
LoadWB NEWPATH and the Workbench will inherit the<br />
new path.<br />
<strong>Amiga</strong> <strong>Computing</strong><br />
MARCH 1997<br />
en inf.<br />
tiiii'i info<br />
Dist into<br />
Lies info<br />
HUI. info<br />
£(or*9».Info<br />
Tooli Info<br />
wO*i»rlup.Inf<br />
7 Workb«>ch 1<br />
following C#?C.<br />
Real wild<br />
child<br />
If I also wanted words that had an i in the<br />
middle you could do this with C#?I#?G. To put<br />
this in more computer oriented context; if you<br />
want to specify just the icon files in a directory<br />
then you would use #?.info to do so, or for<br />
Jpegs you could use #?.jpg.<br />
Things start to get a little more complex<br />
when other wildcards are introduced. Two that<br />
are of most use are the NOT and OR wildcards<br />
represented by the - and | symbols. This helps<br />
you lump together wildcard definitions. So if<br />
you wanted to perform some operation on all<br />
the GIF and Jpeg files this would do the trick:<br />
(#?.gif|#?.jpg). The brackets tell the Shell what<br />
the pattern is and the bar tells it that files<br />
matching either wildcard will do. So any file<br />
ending with .GIF or JPG will be used.<br />
The little squiggle symbol, called a tilde, rep<br />
resents a Boolean not, or tells the Shell to<br />
ignore files that match following file pattern.<br />
This is useful in ASL file requesters that allow<br />
patterns entered to filter the file listing. To get it<br />
to ignore all the icon files you can enter<br />
-•(#?.info) and all the icon files will be<br />
removed from the file list. This can be useful<br />
when using a specific program - if you save all<br />
your files off with the same file extension such<br />
as .ww for Wordworth by using #?.ww in the<br />
file pattern gadget only Wordworth files will<br />
be shown.<br />
You should be aware that the hash and<br />
question mark wildcards are actually two sepa<br />
rate wildcards that when used together just<br />
happen to match any characters. The question<br />
mark will match any single character in a<br />
name. So A?C will match any occurrence of A<br />
and C with any other character in-between<br />
them.<br />
The hash mark is slightly more complex as it<br />
will match zero or more occurrences of a pat<br />
tern. So A#BC will match A and along with any<br />
number of B's in-between them. So AC, ABC<br />
and ABBBC are ail valid matches. As you have<br />
already seen brackets or parenthesise can be<br />
used to enclose wildcard definitions and allow<br />
you to show <strong>Amiga</strong>DOS exactly which set of<br />
characters it should use, this becomes handy<br />
when you need to show <strong>Amiga</strong>DOS that you<br />
want to specify a group of characters to match<br />
and not just a single one. So using A#(BC) you<br />
can tell <strong>Amiga</strong>DOS that you want to match<br />
every A that is followed by any number of BC's.<br />
A final wildcard and one you probably will<br />
not have to use very much in the null character<br />
which <strong>Is</strong> represented with a percent sign and is<br />
just a way of giving the computer a chance to<br />
ignore a match. So A(B|°/a)C will match both<br />
ABC and just AC as you have given the null<br />
option.<br />
CI0K1) 9*« full, 99B9K<br />
731 rull. 31011<br />
100* full, 0K<br />
CK»ln> 42* full, 72M<br />
The latest ASL requester gives you everything ReqTools does including the handy pattern<br />
requester, wildcards crop up quite a lot when dealing with files