Directories with maximum number of files
2018-12-10
72 words
1 min read
Lot of times, I want to find the directories with maximum number of files and so I wrote this quick function to do exactly the same
function count_lines () { oldIFS=$IFS count=0 IFS=$'\n' dir=${1:-.} cd $dir find . -type d |while read line do echo -n "$(find $line -type f |wc -l) $line" echo printf "Directories :: %8d\r" $count >&2 ((count++)) done|sort -n IFS=$oldIFS } # ---------- end of function count_lines ----------
Related Articles:
- 2018/03/19 mv command with progress
- 2015/11/30 Disk usage by file type
- 2014/10/13 nice little bash function to search for running processes
- 2011/01/14 bash 4.0 – new feature mapfile
- 2010/10/13 Quick tip on zipping logs in real time.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.