Combine du and find command

I wish to combine the du -k cmd and find . -mtime -1 command. How do I do that?

My aim is to calculate the size of new files in the current directory and subdirectory that was added in the last one day. How do I do that?
# find . <blah blah> -printf <blah blah>
find: bad option -printf
find: [-H | -L] path-list predicate-list

Open in new window

Who is Participating?
TintinConnect With a Mentor Commented:
Whoops, sorry about that.  I forgot that requirement.

Make it

find . -type f -mtime -1 | xargs du -k | awk '{t+=$1} END {print t}'

and if you wanted it sorted in size order do

find . -type f -mtime -1 | xargs du -k | awk '{t+=$1} END {print t}' | sort -n
find . | xargs du -k | awk '{t+=$1} END {print t}'
QLJAuthor Commented:
not quite right yet.. I was hoping to get something like this (but picked out for those that were new within a day)

9696    ./cur
1       ./new
1       ./tmp
195     ./.Trash/cur
1       ./.Trash/new
1       ./.Trash/tmp
245     ./.Trash
1       ./.Drafts/cur
1       ./.Drafts/new
1       ./.Drafts/tmp
6       ./.Drafts
50      ./.Sent/cur
1       ./.Sent/new
1       ./.Sent/tmp
93      ./.Sent
1       ./.Junk/cur
1       ./.Junk/new
1       ./.Junk/tmp
6       ./.Junk
1       ./.Spam/cur
1       ./.Spam/new
1       ./.Spam/tmp
6       ./.Spam
10602   .
QLJAuthor Commented:
still seems to give a total number.. but I guess it's fine as find . -type f -mtime -1 | xargs du -k gives the breakdown
I thought you wanted the total.  Oh well, as you found out, leaving out the awk line gives you the total for each file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.