Task

Walk a given directory and print the names of files matching a given pattern.

(How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?)


Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree.

Note: Please be careful when running any code presented here.



Related task

   Walk Directory Tree   (read entire directory tree). 


procedure main()
every write(getdirs(".","icn"))  # writes out all directories from the current directory down
end
 
procedure getdirs(s,pat)  #: return a list of directories beneath the directory 's'
local d,f
 
if ( stat(s).mode ? ="d" ) & ( d := open(s) ) then {
      while f := read(d) do 
         if find(pat,f) then 
            suspend f
      close(d)
      }
end