HFS: File masks: Difference between revisions
Line 6: | Line 6: | ||
== Come funziona? == | == Come funziona? == | ||
L'esempio precedente mostra una ''doppia'' maschera file.<br>Presenta due elementi separati da | L'esempio precedente mostra una ''doppia'' maschera file.<br>Presenta due elementi separati da punto e virgola (;): ''*.jpg'' | ||
e ''*.gif''.<br>Il punto e virgola è utilizzato per unire maschere multiple essendo, infatti, un carattere'' "speciale"''.<br>Nelle maschere file possono esistere esclusivamente tre tipi di carattere speciale: ''';''' '''*''' e '''?'''. | |||
== The star (*) == | == The star (*) == |
Revision as of 23:47, 10 January 2007
Cos'è?
Una maschera file ("file mask") denota un set di files.
Un esempio potrebbe essere il seguente: *.jpg;*.gif.
Questo modello denota ogni file con estensione .jpeg e .gif.
Ricorda che i caratteri usati nei nomi dei files non sono "case sensitive": per cui *.jpg e *.JPG (cioè scritto in minuscolo e/o maiuscolo) riferisce esattamente allo stesso set di files.
Come funziona?
L'esempio precedente mostra una doppia maschera file.
Presenta due elementi separati da punto e virgola (;): *.jpg
e *.gif.
Il punto e virgola è utilizzato per unire maschere multiple essendo, infatti, un carattere "speciale".
Nelle maschere file possono esistere esclusivamente tre tipi di carattere speciale: ; * e ?.
The star (*)
The star (also called "asterisk") stands for any string of characters. If the mask contains only the star, it matches ANY file.
If you put an A before the star A*, it matches any file starting with an A.
If you put an A after the star *A, it matches any file ending with an A.
A*B matches any file starting with an A and ending with a B. The example above shows *.jpg : it matches any file ending with .jpg (that is, jpeg images). jpeg files are relatively unusual because they sometimes end with .jpeg and more rarely with .jpe . (The part of a filename that comes after the period is called the file "extension", and is normally limited to three characters.) You could use the mask .jp* to match all types of jpeg files.
The star also matches the null string: A*.jpg matches files like A1.jpg , Adfgg.jpg but also A.jpg.
The question mark (?)
This stands for a single character. Something like A?B matches any filename that is three characters long and starts with an A and ends with a B. The length is fixed to three characters because ? can be replaced by only one character. Thus the ? does not match the null string as the * does.