Page 1 of 1

find command help

Posted: 2018/03/01 14:35:06
by nomad_cale
Hi Everyone!

I need some help with the find command. I'd like to querry pdf files with date and file size in a specific range of date. I have to sum the file size what I get the end of the process.

find / -newermt "2018-01-20" \! -newermt "2018-03-01" -type f -iname '*.pdf' -print0 | xargs -0 du -h >> txt.txt

The first case I get the size and the filename.

find / -type f -iname '*.pdf' -printf "\n%AD %AT %p" -newermt "2018-01-20" \! -newermt "2018-03-01" >> txt.txt

In here I get the date and the filename. I'm beginner in CentOS, so I'd like to ask some help or advice. Thank you!

Re: find command help

Posted: 2018/03/02 19:01:22
by fdisk
Just add -c option (=count) to du command:

Code: Select all

find / -newermt "2018-01-20" \! -newermt "2018-03-01" -type f -iname '*.pdf' -print0 | xargs -0 du -hc

Re: find command help

Posted: 2018/03/10 09:18:38
by nomad_cale
Thank you! :)

The next question how can i write before or after the file in the list?

Re: find command help

Posted: 2018/03/10 20:46:39
by fdisk
Just to get this right: you want to add elements within every line, right? Maybe you can give an minimal example of wanted output.