On 2002.11.22 00:36 Bob Proulx wrote:
Karl O . Pinc <[EMAIL PROTECTED]> [2002-11-18 14:33:30 -0600]: > To keep there error from coming up, I can > > 2>/dev/null > > if [ ! -e . ] ; then ls pattern ; fi > > but niether of these solutions is particularly elegant. > The first throws all errors away, and I want to know if > there are any other errors. The second assumes that > there will only be files in the directory when the directory > also contains files matching <pattern>.
The first is rather like this.for file in pattern ; do if [ ! -f "$file" ]; then echo "$file: no such file" 1>&2 fi done
Sorry.You did not really say what you were trying to do. Therefore it is hard to suggest alternatives.
What I am trying to do is take advantage of the pattern expansion
capabilities of the shell.
I want to pipe the result of the shell's pattern expansion to
the remainder of my program, but I don't want to feed the
right side of the pipe a file that doesn't exist, the pattern
expands to iteslf when there's no matching directory entry.
I attempted to use ls as a filter to remove non-existant
pathnames, a task beyond ls.
You are right, I can filter shell pattern expasion with:
for f in pattern ; do
if [ -e "$f" ] ; then
echo "$f"
fi
done
I'm just searching for an existance filter command, so I don't
have to code the loop. 'ls -d', which lists files which _do_ exist
just rolled off my fingers. I've no compelling reason not to code the loop, just lazyness.
Thanks for the help.
Karl <[EMAIL PROTECTED]>
_______________________________________________
Bug-fileutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-fileutils