[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] BASH: expansion af stjerne *



Kristian Nørgaard <sslug@sslug> writes:

> Det er som om *.txt ikke altid expanderes, som jeg forventer. Jeg har
> ikke helt klar over i hvilke tilfælde det fejler, men ind i mellem får
> jeg en fejl meddelelse, a la:

Ifølge SUSv3 skal mønstre der ikke ekspanderer til nogle filer lades
uændret. Hvis du ikke har nogle filer der hedder noget med .txt vil $f
altså få den ene værdi '*.txt'.

Du bliver nødt til at lave noget ala:

for f in *.txt ; do
    if [ ! -e $f ] ; then 
        continue
    fi

    # Gør noget ved $f
done
  
-- 
 Peter Makholm     |     Have you ever felt trapped inside a Klein bottle?
 sslug@sslug |                                                      
 http://hacking.dk |                                                      


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *