Complete.Org: Mailing Lists: Archives: linux-help: January 2001:
[linux-help] Re: Quick BASH/Perl Question
Home

[linux-help] Re: Quick BASH/Perl Question

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: Quick BASH/Perl Question
From: Curtis Hawthorne <cghawthorne@xxxxxxxxx>
Date: Sat, 13 Jan 2001 12:14:22 -0800 (PST)
Reply-to: linux-help@xxxxxxxxx

Thanks for all your help, everyone!  Works great.
--- Tom Hull <thull@xxxxxxxxxxx> wrote:
> 
> Jeff Vian wrote:
> > 
> > Using John's answer, the following will easily
> work
> > 
> > for fname in `ls *.log`
> > do
> >     if [ -f ${fname} ]; then
> >         echo "${fname} exists"
> >     fi
> > done
> 
> ls(1) will only print the names of files which
> exist, so the
> test -f is not necessary. fname will not be set if
> there are
> no *.log files.
> 
> however, ls will print an ugly error message to
> stderr, so
> 
>   2>/dev/null
> 
> may be advised. also, if *.log returns a directory,
> ls will
> print out a list of its contents, which is not what
> you want.
> ergo:
> 
>   for fname in `ls -d *.log 2>/dev/null`
>   do
>     echo "${fname} exists"
>   done
> 
> -- 
> /*
>  *  Tom Hull * thull at kscable.com *
> http://www.ocston.org/~thull/
>  */
> 
> -- This is the linux-help@xxxxxxxxx list.  To
> unsubscribe,
> visit
>
http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]