find command help

Comments, suggestions, compliments, etc
Post Reply
nomad_cale
Posts: 2
Joined: 2018/03/01 14:25:14

find command help

Post by nomad_cale » 2018/03/01 14:35:06

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!

User avatar
fdisk
Posts: 42
Joined: 2017/11/04 00:59:56

Re: find command help

Post by fdisk » 2018/03/02 19:01:22

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

nomad_cale
Posts: 2
Joined: 2018/03/01 14:25:14

Re: find command help

Post by nomad_cale » 2018/03/10 09:18:38

Thank you! :)

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

User avatar
fdisk
Posts: 42
Joined: 2017/11/04 00:59:56

Re: find command help

Post by fdisk » 2018/03/10 20:46:39

Just to get this right: you want to add elements within every line, right? Maybe you can give an minimal example of wanted output.

Post Reply