From: Tanaka Akira Date: 2002-03-24T15:10:43+09:00 Subject: [ruby-dev:16558] Re: File.fnmatch (Re: [rubyist:1286] Re: ARGV の機能) In article <20020324.143726.89024092.JCA02266@nifty.ne.jp>, Koji Arai writes: > $B!V(Bglob$B!W$NDj5A$C$F$J$s$G$7$g$&$M!)@N$+$i$o$+$i$J$$$s$G$9$,!#(B $B$U$`!#(BJargon $B$K$O(B :glob: /glob/, _not_ /glohb/ v.,n. [Unix; common] To expand special characters in a wildcarded name, or the act of so doing (the action is also called `globbing'). The Unix conventions for filename wildcarding have become sufficiently pervasive that many hackers use some of them in written English, especially in email or news on technical topics. Those commonly encountered include the following: * wildcard for any string (see also {UN*X}) ? wildcard for any single character (generally read this way only at the beginning or in the middle of a word) [] delimits a wildcard matching any of the enclosed characters {} alternation of comma-separated alternatives; thus, `foo{baz,qux}' would be read as `foobaz' or `fooqux' Some examples: "He said his name was [KC]arl" (expresses ambiguity). "I don't read talk.politics.*" (any of the talk.politics subgroups on {Usenet}). Other examples are given under the entry for {X}. Note that glob patterns are similar, but not identical, to those used in {regexp}s. Historical note: The jargon usage derives from `glob', the name of a subprogram that expanded wildcards in archaic pre-Bourne versions of the Unix shell. $B$H=q$$$F$"$j$^$9$M!#$&$%$`!"$3$l$@$H(B {} $B$bF~$C$F$k$+!#(B{} $B$O%U%!%$%k$H(B $B$7$F$OB8:_$7$J$$$N$b=P$F$/$k$+$i0c$&$H$7$?$[$&$,AGD>$@$H;W$&$s$@$1$I!"(B glob $B$K4^$a$kJ}$,0lHLE*$J$N$+$bCN$l$^$;$s!#(B $B$=$l$O$=$l$H$7$F!"(Bpre-Bourne version $B$H$$$&$o$1$G(B Version 6 $B$r8+$F$_$k(B $B$H(B... glob $B$H$$$&%3%^%s%I$N$,$"$k$s$G$9$M$'!#%=!<%9$NKAF,$K$O(B /* global command -- glob params "*" in params matches r.e ".*" "?" in params matches r.e. "." "[...]" in params matches character class "[...a-z...]" in params matches a through z. perform command with argument list constructed as follows: if param does not contain "*", "[", or "?", use it as is if it does, find all files in current directory which match the param, sort them, and use them prepend the command name with "/bin" or "/usr/bin" as required. */ $B$H=q$$$F$"$k$+$i$?$V$s(B global $B$+$iMh$F$k$N$+$J$!!#$3$3$K$O(B {..} $B$O$"$j(B $B$^$;$s$,!"$^$!(B csh $B0JA0$@$+$i$H$$$&0J>e$N0UL#$O$J$$$+!#(B -- [$BEDCf(B $BE/(B][$B$?$J$+(B $B$"$-$i(B][Tanaka Akira] $B!V$U$($m(B! $B$o$+$a$A$c$s:n@o$G$9$(C"=$B!W(B(Little Worker, $B7KM7@84](B)