Idiom for $(ls -d $pattern 2>/dev/null)

das at lanai.cs.ucla.edu das at lanai.cs.ucla.edu
Sat Mar 18 06:28:24 AEST 1989


Do you have a favorite idiom for (ksh syntax):
	$(ls -d $pattern 2>/dev/null)
that does not involve invocation of a separate process and is not aesthetically
unpleasant?  The intent is that if any filenames match the pattern, then use
them; otherwise, use the null string.  This shows up when you want to say
	for f in *
(Which is not what you really want, since if the directory is empty, f takes on
the value "*").

-- David Smallberg, das at cs.ucla.edu, ...!{uunet,ucbvax,rutgers}!cs.ucla.edu!das



More information about the Comp.unix.questions mailing list