From: Sean O'Halpin Date: 2012-08-25T18:51:32+09:00 Subject: Re: Parsing unix filenames from STDIN On Sat, Aug 25, 2012 at 12:57 AM, David Jacobs wrote: > How can I parse filenames read from STDIN via the standard Unix parsing rules (without duplicating said rules)? All of the following would be parsed as coherent file names: > > file.txt > my\ file.txt > "my file.txt" > > A nice addition would be that *.txt would use Bash expansion to find the appropriate files. Use Shellwords to handle shell escaped strings and Dir[] to expand wildcards: require 'shellwords' while line = STDIN.gets filename = Shellwords.shellwords(line).join('') p filename # expand wildcards p Dir[filename] end Regards, Sean