[linux-help] Re: Quick BASH/Perl Question
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Using John's answer, the following will easily work
for fname in `ls *.log`
do
if [ -f ${fname} ]; then
echo "${fname} exists"
fi
done
----- Original Message -----
From: Curtis Hawthorne <cghawthorne@xxxxxxxxx>
To: <linux-help@xxxxxxxxx>
Sent: Wednesday, January 10, 2001 6:14 PM
Subject: [linux-help] Re: Quick BASH/Perl Question
>
> That still gives me the same error message. In the
> directory, there are about 10 or so .log files in the
> directory, and I think that by saying *.log, the shell
> will expand it to list individually every file. Any
> other ideas?
>
> --- John Reinke <jmreinke@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Wed, 10 Jan 2001, Curtis Hawthorne wrote:
> >
> > > First, in BASH, how do I test for the presence of
> > any
> > > .log (*.log) file in a directory? If I do "test
> > -a
> > > *.log" it says there's too many arguments.
> >
> > I always use an if contruct, although I guess it's
> > technically still test:
> >
> > if [ -f *.log ]; then
> > echo "File exists"
> > fi
> >
> > This tests if the file exists and is a regular file,
> > you can use -d to
> > test for a directory, etc...
> >
> > For a quicker reply, I'll let someone else answer
> > the other question,
> > since my perl is rusty at the moment.
> >
> >
> > > Second, in Perl what's the easiset way to grab the
> > > first letter of a string, preferably without
> > splitting
> > > the whole thing into a letter by letter array?
> > >
> > > Thanks!
> > >
> > > Curtis
> >
> >
> > -- This is the linux-help@xxxxxxxxx list. To
> > unsubscribe,
> > visit
> >
> http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos - Share your holiday photos online!
> http://photos.yahoo.com/
>
> -- This is the linux-help@xxxxxxxxx list. To unsubscribe,
> visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
>
-- This is the linux-help@xxxxxxxxx list. To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
|
|