[GLLUG] Shell Scripting

Melson, Paul PMelson at sequoianet.com
Tue Jul 22 10:02:28 EDT 2003


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,

-- 
Darrel Clute, CCNP/CCDP

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT/B d+ s+: a--- C++++ UL++++ P+ L+++ E--- W++ N+ o+ K- w--- O-- M V--
PS
PE Y+ PGP- t+ 5+ X+ R tv+ b+ DI+ !D G+ e h! r-- y-
------END GEEK CODE BLOCK------

To Decipher Code - http://www.ebb.org/ungeek/

To Learn About Code - http://www.geekcode.com/geek.html
_______________________________________________
linux-user mailing list
linux-user at egr.msu.edu
http://www.egr.msu.edu/mailman/listinfo/linux-user



More information about the linux-user mailing list