2019-03-08

How to get the number of files in a folder as a variable?




Reference URL: https://stackoverflow.com/a/11132110/676104






How about:
count=$(find .. -maxdepth 1 -type f|wc -l)
echo $count
let count=count+1 # Increase by one, for the next file number
echo $count
Note that this solution is not efficient: it spawns sub shells for the find and wc commands, but it should work.

















No comments:

Google Referrals