bash if file exists
Mark Richards
mark.richards at massmicro.com
Fri Apr 4 20:51:58 EDT 2008
David Rosenstrauch wrote:
> Matt Brodeur wrote:
>> On Thu, Apr 03, 2008 at 01:27:56PM -0400, Eric Chadbourne wrote:
>>> Hi all. Help I'm having a brain freeze. How come this doesn't work?
>>> Thanks. - Eric C.
>>>
>>> if [ -a *.zip ] ;
>>> then
>>> echo "there is a zip";
>>> else
>>> echo " no zip found";
>>> fi
>>
>> Just because you don't have *enough* different answers yet:
>>
>> set -- *.zip
>> if [ -f "${1}" ] ; then
>
> Por favor - could you explain this one?
Set the parameter list to all files meeting the specification.
Test to see if ${1} is a valid file and then
do something with it.
${1} could be iterated through so you can get each file.
Pretty good for chicken scratch.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Discuss
mailing list