[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Oldest files

I have a directory that has sub directories and I need to find the oldest 10 files in each of the sub diretories, I have a command that does the search but it comes back with the 10 newest files
and I need the 10 oldest, what do I need to change.


command that I need to modify


# for dirs in `find /mail/queues/ -type d -depth` ; do echo $dirs; ls -Altr $dirs | tail -10; done


Thanks,

0
bt707
Asked:
bt707
  • 3
1 Solution
 
yuzhCommented:
You need to get rid of the "r" in your command, make it :

# for dirs in `find /mail/queues/ -type d -depth` ; do echo $dirs; ls -Alt $dirs | tail -10; done


man ls
to learn more details.


0
 
wesly_chenCommented:
Oops, my mistake.
http://www.experts-exchange.com/Operating_Systems/Solaris/Q_21221741.html

yuzh is right.

Original:
# for dirs in `find /mail/queues/ -type d -depth` ; do echo $dirs; ls -Altr $dirs | tail -10; done
                                                                                                  ^^^
Modified:
# for dirs in `find /mail/queues/ -type d -depth` ; do echo $dirs; ls -Alt $dirs | tail -10; done
                                                                                                 ^^^

As my experience, /mail/queue stores all the emails in queue and it doesn't have subdirectory. (Please correct me
if I were wrong)
So I will simply the script to
# ls -lt /mail/queues/ | grep '^-' | tail -10

Regards,

Wesly
0
 
yuzhCommented:
Hi Wesly,

     The standard sendmail configuration use /var/spool/mqueue,  bt707 might use
multiple mail queues for the sendmail config, so it is possible to have subdirectories.

     see http://people.freenet.de/slgig/op_en/operations.html#queues

     for more details.
0
 
bt707Author Commented:
Thanks yuzh, I took the 'r' out as you said and that fixed it.


Yes we do have multiple directories, we use Sun One Iplanet and it uses on directory for each channel with about 12 to 20 sub directories, they get created automatically as needed.


Thanks agian,
0
 
yuzhCommented:
You are welcome!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now