Re: Elegant bash solution for testing existence of any files?
- From: chriswaltham@xxxxxxxxx
- Date: 10 Jul 2006 11:35:44 -0700
Janis Papanagnou wrote:
chriswaltham@xxxxxxxxx wrote:
I'm trying to write a reasonably basic script to convert varied image
file formats to EPS-formatted files. The script runs every 15 seconds,
and checks for the existence of *.{gif,jpg,tiff} files at that interval
to decide whether or not it has something to process. The files are
"fed" into the directory the script resides in automatically.
At the moment, I'm using the "if [ -a * ]" syntax to start a processing
loop, but that is incorrect if >1 files exist.
You are using * so I assume that only files of the given types are
present in that directory. You may set - * and then test whether
$1 is an accessible file. (But why not simply loop over the files
of given type?)
Janis
I was using * as the extension of the files doesn't matter; only that
file(s) exist. Once it's ascertained that files exist, the conversion
process begins -- amongst other things it changes filename case to
ensure sanity, and then (depending on the file extension) does the
processing.
This is one of those times where I can think of a ton of ways to solve
the problem, but can't help but think there's an easier/better/more
elegant way than this:
ls_output=`ls *.tif*`
if [ -z $ls_output ]
then
echo "no files exist to convert, skipping..."
else
echo "files exist, loading conversion process"
convertProc # run conversion (incl. sanity & format checking)
fi
Chris
.
- Follow-Ups:
- Re: Elegant bash solution for testing existence of any files?
- From: Jon LaBadie
- Re: Elegant bash solution for testing existence of any files?
- References:
- Elegant bash solution for testing existence of any files?
- From: chriswaltham
- Re: Elegant bash solution for testing existence of any files?
- From: Janis Papanagnou
- Elegant bash solution for testing existence of any files?
- Prev by Date: Re: PID of running commands.
- Next by Date: Re: Elegant bash solution for testing existence of any files?
- Previous by thread: Re: Elegant bash solution for testing existence of any files?
- Next by thread: Re: Elegant bash solution for testing existence of any files?
- Index(es):
Relevant Pages
|