On Fri, Feb 11, 2011 at 06:13, Michael Rasmussen <[email protected]> wrote:
> bash file test -e will tell you if a single file exists but
>    if [ -e ~/Maildir/.aspambin/cur/* ]; then
> will croak with "too many arguments" if there is more than one file

# might be a cleaner way, but this should work...
if [ "$(ls ~/Maildir/.aspambin/cur/* 2>/dev/null)" ]; then ...


> conversly a construct like
>    for S in ~/Maildir/.aspambin/cur/*
> will attempt to act on a file named * if the directory is empty.

How about one of the following?:

# doesn't handle files w/ spaces, possible injection
for S in $(ls ~/Maildir/.aspambin/cur) ...

# handles files with spaces and other problematic characters
find ~/Maildir/.aspambin/cur -print0 | xargs -0 -n1 ...


Cheers,

Daniel Hedlund
[email protected]
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to