Skip to content

Instantly share code, notes, and snippets.

@tajnymag
Created November 9, 2020 09:45
Show Gist options
  • Save tajnymag/6226775f9c942c375635b6d84933648c to your computer and use it in GitHub Desktop.
Save tajnymag/6226775f9c942c375635b6d84933648c to your computer and use it in GitHub Desktop.
#!/bin/bash
# nums : script vypise pocet souboru a adresaru
if [ $# -eq 0 ]; then
set -- "."
fi
for dir in $*; do
if [ ! -d "$dir" ]; then
echo "$0 : $dir neni adresar"
else
echo "$dir :"
fcount=0
flcount=0
dcount=0
dlcount=0
for file in $(find "$dir" -maxdepth 1 2>/dev/null); do
if [ -f "$file" -a ! -L "$file" ]; then
fcount=$(expr $fcount + 1)
elif [ -f "$file" -a -L "$file" ]; then
flcount=$(expr $flcount + 1)
elif [ -d "$file" -a ! -L "$file" ]; then
dcount=$(expr $dcount + 1)
elif [ -d "$file" -a -L "$file" ]; then
dlcount=$(expr $dlcount + 1)
fi
done
echo "$dcount adresaru $fcount obyčejných souborů $dlcount symbolických linků na adresáře $flcount symbolických linků na obyčejné soubory"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment