I hate globbing. Whoever thought that it was a good idea to let the shell snaffle the arguments you’ve given to a program needs to be pushed off somewhere high onto some burning cactii.
You can turn it off in the shell, but this makes most unix commands useless since they don’t do the file expansion themselves (like they should).
In ruby…
for f in Dir.glob("/home/r/tmp/**/*")
File.open(f) { |file|
puts "filename #{f}"
} if File.file?(f)
end
python…
import glob, os
for root, dirs, files in os.walk('/home/r/tmp'):
for f in files: print 'file -> ', os.path.join(root,f)
The Common Lisp pathname stuff can be a bit confusing, which is a pity because it does have some nice tricks up its sleeve.
You build the directory section of the pathname as a list taking keyword arguments :wild where you want to match at one directory level and :wild-inferiors when you want to recurse.
CL-USER> (make-pathname :name :wild
:type :wild
:directory (list :absolute "home" "r" "tmp" :wild-inferiors))
#P"/home/r/tmp/**/*.*"
so running (DIRECTORY #P"/home/r/tmp/**/*.*") should give you all the files in the tmp directory and below. Some compilers though take directories themselves to be files and others don’t, so you might need to use FILE-NAMESTRING to see if the filename part of the path is nil i.e. its a directory.



