Bash Script Ques

Ben Duncan bns
Mon May 17 11:48:11 PDT 2004


Hmmmm ....

#!/bin/sh
# Script
for file in `ls myfile*`
do
   if [ -f $file ]
   then
      DO SOMTHING HERE
    fi
done




Michael Hipp wrote:
> Hello, first post (in a long time) ...
> 
> I thought to do something like:
> 
> if [ -f myfile* ]; then
>    # do something
> fi
> 
> That's to find if there are one or more like myfile001, myfile002, but 
> it reports an error "too many arguments" if there is more than one. Any 
> simple/elegant way to do this?
> 
> Thanks,
> Michael
> 
> _______________________________________________
> Linux-users mailing list
> Linux-users at linux-sxs.org
> Unsubscribe/Suspend/Etc -> 
> http://www.linux-sxs.org/mailman/listinfo/linux-users
> 
> .
> 


-- 
Ben Duncan   Phone (601)-355-2574     Fax (601)-355-2573   Cell (601)-946-1220
                         Business Network Solutions
                      336 Elton Road  Jackson MS, 39212
    "Software is like Sex, it is better when it's free" - Linus Torvalds



More information about the Linux-users mailing list