regex - Linux disk usage of files that match expression -
i have mounted hard-drive multi-users this:
/hdd1/user1 /hdd1/user2 /hdd1/user3
i'd in each user's folder, find files match expression (say, "*.txt"
), , sum space used files, , report on per user base:
user1: x bytes user2: y bytes user3: z bytes
i found directories of files with:
find /hdd1/ -name "*.txt" | rev | cut -d"/" -f2- | rev | uniq > txtfiles.dat
i thought i'd use loop go through each line in txtfiles.dat
calculating disk usage in each folder, seems cumbersome. there neater way this? du
looks in each user's folder counting files match expression?
du
takes list, , size individual files if given -a
option , produce total -c
option.
in bash shell $(cmd)
output of running cmd
.
so, putting together, sizes of .txt files, 1 run:
du -ac $(find . -name '*.txt')
Comments
Post a Comment