Print the directory with the most files in unix/linux -
i'm new stack overflow, patient.
i'm in directory contains both files , directories. want command print out name of directory (out of few specified directories) has greatest number of files in it.
here go:
for d in */ ; echo "$d" $(find $d -type f | wc -l); done | sort -n -k 2 explanation:
for d in * loop through directories only
echo "$d" $(find $d -type f | wc -l) show directory name , count of files (recursively)
sort -n -k 2 sort numerically output of whole thing (for loop) using second field (the number of files)
Comments
Post a Comment