[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] Hvorfor er 0 == 1?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 10 Sep 2007 00:36:08 +0200
Jens Bang <sslug@sslug> wrote:

> 
> Hvorfor er FileCount lig med 1 både når der er ét backup*-directory
> og når der ikke er noget backup*-directory? 
> 
Kunne det ikke skyldes, at hvis du ikke videresender stderr
til /dev/null, så vil fejlmeddelelser blive medtalt?
ls backup* giver denne fejlmeddelelse, hvis intet matcher:
ls: backup*: No such file or directory

Det virker sådan her:
#!/bin/sh
FileCount=0

for X in $(ls backup* 2> /dev/null)
do
    FileCount=$((FileCount+1))
done

Vær iøvrigt opmærksom på, at ls medtæller både katalognavne og indhold
i kataloger. Har du f.eks følgende:

backup0001
    |
    ---- file1
    |
    ---- file2

giver ovenstående 3 som resultat.

- -- 
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917
A computer is like air conditioning: it becomes useless when you open
windows.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG5HtSVErYVePoCRcRAmt7AKCMCLKFcp4xLdWTfl7eKzbiYSB1tACfYXwh
WQ3RDRmRO9B6HAsmxTBk3JA=
=yhZw
-----END PGP SIGNATURE-----


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-10-01, 02:01 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] *