linux - Script to count files (Bash) -


i trying create script goes through archive location , counts how many files there are.

this have far.

#!/bin/bash  archive_location="location/archive/" count=0  files in $archive_location/* $archive_location/.*     count=$($count+1) done  echo "file count: " $count 

when run file line 8: 0+1: command not found & line 8: +1: command not found

please me. first time creating bash script.

you run find through wc

find /path/to/search -type f | wc -l 

edit:

since need write loop need correct counter 1 of following:

count=$((count+1)) 

or

let count=$count+1 

or performance declare count integer , can use += operator:

declare -i count count+=1 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -