Domain changed to archive.palanq.win . Feb 14-25 still awaits import.
[16 / 7 / ?]

ITT: Linux scripting help.

No.61979 View ViewReplyOriginalReport
I really don't get what I'm doing wrong in this script. The purpose of it is to print the total number of files, folders and the sum of the two. Yet it doesn't produce the results that I want. Could someone help me out?

#!/bin/bash
vector=(`ls /home/smallverse/Scripts`)
ct=0
file=0
dir=0

for ct in "${vector[@]}"
do
if [ -f ${vector[$ct]} ]
then
let file++
else
let dir++
fi

done
echo "Files: $file"
echo "Folders: $dir"
echo "Total: ${#vector[@]}"