Hallo Michael, it's not Ruby, that expands your argument, but the shell. And therefore you got no other chance than escaping the argument there. This can be done using quotes or a backslash in front of each special character > ruby -e "puts ARGV" \*.txt Best, Gregor On Jun 9, 11:39 am, Michael Jia <z... / yahoo.com> wrote: > I want to pass in wildcard file names, and use it to match file names > located in different directories. For example, *.txt will match file > such as "my.txt", "you.txt", etc. > > However, I found out ruby intepreter automatically expands "*.txt" > command argument to a array of filenames which matches that wildcard in > the current directory. > > For example: > > C:\working>dir *.txt > > 05/10/2007 03:24 PM 46,101 config.txt > 11/23/2004 11:54 AM 361 tips.txt > 2 File(s) 46,462 bytes > > If you do, > > C:\working>ruby -e "puts ARGV" *.txt > config.txt > tips.txt > > Ruby converts string *.txt into the matching filenames and pass in the > expanded array as the new argument. > > This *nice* trick sometime creates trouble. > > In my case, I want to use 'ARGV[0]' to match filenames in a different > location. But ARGV[0] is not "*.txt" as my expected. It was changed by > ruby. In fact, it is "config.txt" in this case. > > One way to correct it is to always ask user to use single-quoted string: > > C:\working>ruby -e "puts ARGV" '*.txt' > *.txt > > -- > Posted viahttp://www.ruby-forum.com/.