[GLLUG] Shell Scripting

Sean picasso at madflower.com
Tue Jul 22 09:40:54 EDT 2003


You could also do something like this to get the actual filenames:

for i in `ls *.jpg`
do 
echo my jpeg file is $i
done



On Tue, 22 Jul 2003, Melson, Paul wrote:

> Try this:
> 
> jpgz=`ls /home/darrel/*.jpg 2>/dev/null`
> if [ "${jpgz}x" != "x" ]; then
>   # do this if there are files
>   echo "dude!  what does mine say?"
> else
>   # do this if no files
>   echo "sweet!  what does mine say?"
> fi
> 
> Hope that helps!
> 
> PaulM
> 
> 
> -----Original Message-----
> From: Darrel Ray Clute, III [mailto:darrel_clute at yahoo.com]
> Sent: Tuesday, July 22, 2003 1:00 AM
> To: GLLUG
> Subject: [GLLUG] Shell Scripting
> 
> 
> Hi All!
> 
> I am trying to write a shell script that will test for
> the existance of a file with a specific extension.
> 
> For example:
> 
> if [ -f /home/darrel/*.jpg ]; then
>      do stuff here...
> fi
> 
> It works great if I have it look for a specific file,
> but will not work with any type of quoting fir the *.
> 
> I've also tried the 'test' command, but it doesn't
> like multiple files either.
> 
> Any suggestions or hints as to where to go from here?
> 
> Thanks,
> 
> 




More information about the linux-user mailing list