[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?



On Monday 10 September 2007, Jens Bang wrote:
> Jeg sidder og roder med et bash-script. Og er faldet over noget underligt.
> Jeg vil gerne tælle antallet af directories i det aktuelle directory der
> hedder noget med backup (altså dem der vises med ls backup*). Reelt hedder
> de backup0000, backup0001 osv.
>
> Jeg tæller dem med denne kode:
>
> FileCount=0
>
> for X in backup*
> do
>   FileCount=$((FileCount+1))
> done
>
> Hvorfor er FileCount lig med 1 både når der er ét backup*-directory og når
> der ikke er noget backup*-directory?

det kan gøres en del kortere:

sslug@sslug ~/backuptest $ ls
backup0000  backup0001  backup0002  backup0003  backup0004
sslug@sslug ~/backuptest $ ls backup0001/
file
sslug@sslug ~/backuptest $ ls -d backup* | wc -l
5

-- 
regards
Bjørn Hartfelt // bjuhn_com


 
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] *