LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-09-2015, 02:52 AM   #1
skoda
Member
 
Registered: Jun 2013
Posts: 111

Rep: Reputation: Disabled
Find command confusion


Hi folks,

what is the diffrent between below two commands.

Code:
#find /home/*/mail/ -type f -mtime +547 -exec du -ch {} +
it shows only 208 MB Total

But, if i execute the below command, i get 1.1G total
Code:
#find -P /home/*/mail/ -mindepth 1 -maxdepth 1 -mtime '+547' -exec du -ch {} +

Last edited by skoda; 11-09-2015 at 02:53 AM.
 
Old 11-09-2015, 03:03 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
the first thing I would try is just echo /home/*/mail/ to see what is that exactly. Next, you can try strace the find command to see how is it working.
 
Old 11-09-2015, 03:10 AM   #3
skoda
Member
 
Registered: Jun 2013
Posts: 111

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
the first thing I would try is just echo /home/*/mail/ to see what is that exactly. Next, you can try strace the find command to see how is it working.
Hi buddy,
here is a sample out oput for echo.

Quote:
echo /home/*/mail/
/home/ichilan/mail/
/home/imssafe/mail/
/home/lbilad1/mail/
/home/lhamidh/mail/
/home/lhudalk/mail/
/home/lwasath/mail/
/home/namdesi/mail/
/home/onelk/mail/
/home/iyawan/mail/
 
Old 11-09-2015, 03:12 AM   #4
skoda
Member
 
Registered: Jun 2013
Posts: 111

Original Poster
Rep: Reputation: Disabled
actually this is the exim mail server folder in a web server.

Last edited by skoda; 11-09-2015 at 03:14 AM.
 
Old 11-09-2015, 03:14 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
that won't help me to solve it but you can now check strace find to see what's happening.
 
Old 11-09-2015, 03:35 AM   #6
skoda
Member
 
Registered: Jun 2013
Posts: 111

Original Poster
Rep: Reputation: Disabled
Thanks buddy for the introduction of strace command. ill have a look.
 
Old 11-09-2015, 03:45 AM   #7
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by skoda View Post
Hi folks,

what is the diffrent between below two commands.

Code:
#find /home/*/mail/ -type f -mtime +547 -exec du -ch {} +
it shows only 208 MB Total

But, if i execute the below command, i get 1.1G total
Code:
#find -P /home/*/mail/ -mindepth 1 -maxdepth 1 -mtime '+547' -exec du -ch {} +
Puzzling! To get to the bottom of this, strace is perhaps a bit too heavy of a tool.

I would start with a simple
Code:
#find /home/*/mail/ -type f -mtime +547 -exec /bin/echo {} + >/tmp/findout1
#find -P /home/*/mail/ -mindepth 1 -maxdepth 1 -mtime '+547' -exec /bin/echo {} + >/tmp/findout2
then compare findout1 and findout2. Breathlessly awaiting your result!
 
Old 11-09-2015, 04:11 AM   #8
skoda
Member
 
Registered: Jun 2013
Posts: 111

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Puzzling! To get to the bottom of this, strace is perhaps a bit too heavy of a tool.

I would start with a simple
Code:
#find /home/*/mail/ -type f -mtime +547 -exec /bin/echo {} + >/tmp/findout1
#find -P /home/*/mail/ -mindepth 1 -maxdepth 1 -mtime '+547' -exec /bin/echo {} + >/tmp/findout2
then compare findout1 and findout2. Breathlessly awaiting your result!

findout1 sample

Quote:
/home/chxxxxx/mail/xxxflower.com/mayada/.Sent/cur/1373376578.M370013P26657.host.xxxxx.com,S=365561,W=370345:2,S
/home/starxxxxx/mail/xxxaent.com/rizan/dovecot-uidvalidity.50cc8dbb
/home/abxxxxx/mail/xxxxxings.co/khan/.hiltiop/cur/1388727241.H349616P6578.host.cxxxxxx.com,S=1590:2,S
findout2 sample
Quote:
/home/xxxxlan/mail/xxxxxx.com
/home/xxxxsath/mail/.Drafts
/home/xxxxtain/mail/dovecot.index.log

Last edited by skoda; 11-09-2015 at 04:16 AM.
 
Old 11-09-2015, 05:36 AM   #9
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by skoda View Post
findout1 sample
...
findout2 sample
...
You have to check what's different between the two; samples won't cut it. A simple diff should suffice.
And if there is no difference, I will be even more puzzled
 
Old 11-09-2015, 05:42 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
From the current output I would think the answer is already obvious, the one with a min/max depth stops at the first level after /home/*/mail and then you get a total of that, whereas the other find
works its way down to a single file level and provides the information back, some of these files may never be found if first level after mail does not hold true to the mtime used in first example.

Of course, I could be wrong, but that is what I see
 
Old 11-09-2015, 06:35 AM   #11
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
What's strange though is the fact that the find that stops at the first level yields 1.1GB, whereas the unlimited find only comes up with 200MB. Had it been the opposite, it would have been a clear cut case for me.
Another difference: The unlimited find only looks at regular files. But can there be 900MB of directories and symbolic links?
 
Old 11-09-2015, 07:05 AM   #12
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
hmmm ... I see where you are coming from, however, if the directory in the second command, where there is no restriction on file, could easily contain more than files matching the criteria add up to.
My thinking is that whilst the directory now matches the mtime, there may be little to no actual files that do, so the first find would not have gone there.
 
Old 11-09-2015, 08:33 AM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,958

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
Quote:
Originally Posted by skoda View Post
Hi folks,

what is the diffrent between below two commands.

Code:
#find /home/*/mail/ -type f -mtime +547 -exec du -ch {} +
it shows only 208 MB Total
That totals the space for all ordinary files older than 547 days.

Quote:
But, if i execute the below command, i get 1.1G total
Code:
#find -P /home/*/mail/ -mindepth 1 -maxdepth 1 -mtime '+547' -exec du -ch {} +
That shows the total space used (all the files) under any directories older than 547 days.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
confusion on listing disk by fdisk -l command ouput. bharatlalgupta Red Hat 2 04-11-2012 05:07 AM
Linux find command -perm mode confusion diamond_D Linux - Newbie 2 03-05-2012 08:59 PM
[SOLVED] Confusion with locales: keep english command output lich000king Linux From Scratch 3 06-28-2011 02:42 PM
[SOLVED] Cat command confusion. nnjond Linux - Newbie 6 08-12-2010 10:16 AM
confusion regarding a command rajaneesh Linux - Networking 2 01-01-2010 01:54 AM


All times are GMT -5. The time now is 10:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration