10-07-2006
Finding the oldest file in a particular directory
Hi all,
I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file.
Are there any options available with the "find" command to do this..
Thanks in advance for your help
Pavan
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I'm writing a script to find the oldest file in a directory. I know this can be done by using ls -rt | tail -1 but these are rather large directories and that can be somewhat slow since the script will be running constantly.
Are there any other ways to do this that would be faster? I looked to... (2 Replies)
Discussion started by: bergerj3
2 Replies
2. Shell Programming and Scripting
Hi all,
I need your assistance in removing the oldest file in a directory.
I posted the same thread 3 days back and I got the following answer
ls -1 -t | tail -1 | xargs rm
which is not covering the case when there are directories older than the oldest file.
So, could you please... (2 Replies)
Discussion started by: pavan_movva
2 Replies
3. Shell Programming and Scripting
Hi, Please help me out
I want to grep the oldest file in a directory,
could I use "ls" command?
and how?
thanx in advance (1 Reply)
Discussion started by: ericaworld
1 Replies
4. Shell Programming and Scripting
I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves.
Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies
5. Shell Programming and Scripting
I am using a bash script to perform some automated maintenance on files in a directory. When I run the script using $sh -x script.sh <directory> the script works fine. It sets the variable to the oldest file, and continues on. However when I run the script like this $./script.sh <directory>, it... (5 Replies)
Discussion started by: spaceherpe61
5 Replies
6. Shell Programming and Scripting
This might just be one command.
Any1 having the solution?
Thanks,
Rahul. (25 Replies)
Discussion started by: rahulrathod
25 Replies
7. Shell Programming and Scripting
Hi:-
I need help with a script I need to modify: - what's the best/easiest way to find out the oldest file in a directory and then move this file to another directory?
Thanks, (5 Replies)
Discussion started by: janet
5 Replies
8. UNIX and Linux Applications
I am trying to determine the oldest and most recent files in a huge directory. I am using an ls -tr statement outside my find statement. The directory is too big and I am getting an "arg list too long" error. Is there something I can put in my find statement that doesn't create a list to... (2 Replies)
Discussion started by: hiyofjord
2 Replies
9. Shell Programming and Scripting
Hey! I have found similar posts both here and on other sites regarding this, but I cannot seem to get my script to work. I want to delete the oldest file in a test directory if there are more than two files. My script is currently:
#!/bin/bash
MEPATH=/usr/local/bin/test
FILECOUNT=`ls... (4 Replies)
Discussion started by: Immolation
4 Replies
10. UNIX for Advanced & Expert Users
There are some 25,000 files in 7,000 directories in my source library and I am trying to find oldest files. I am running this find:
find /usr/mysrc -name "*." -type f -mtime +8000 -exec ls -l {} 2>/dev/null
and playing with the days parameter for mtime, but the output is not sorted... (3 Replies)
Discussion started by: migurus
3 Replies
LEARN ABOUT DEBIAN
wa_keyring
WA_KEYRING(1) WebAuth WA_KEYRING(1)
NAME
wa_keyring - WebAuth keyring manipulation tool
SYNOPSIS
wa_keyring [--hv] -f file command [arg ...]
wa_keyring -f keyring add valid-after
wa_keyring -f keyring gc oldest-valid-after-to-keep
wa_keyring -f keyring list
wa_keyring -f keyring remove id
DESCRIPTION
wa_keyring is a command line tool to manage WebAuth key ring files, which contain the private AES keys used by mod_webauth and mod_webkdc.
It supports the following individual commands:
add valid-after
Adds a new key to the key ring. valid-after uses the format:
nnnn[s|m|h|d|w]
to indicate a time relative to the current time. The units for the time are specified by appending a single letter. That letter can be
any of s, m, h, d, or w, which correspond to seconds, minutes, hours, days, and weeks respectively.
For example: 10d is 10 days from the current time, and -60d is 60 days before the current time.
gc oldest-valid-after-to-keep
Garbage collects (removes) old keys on the key ring. Any keys with a valid-after date older then the specified time will be removed
from the key ring.
The format for oldest-valid-after-to-keep is the same as valid-after from the add command. Note that this means that times given to
the gc command should generally be negative, to remove keys that have expired in the past.
list
Lists all the keys in the key ring. By default, a brief listing is used, but a verbose listing can be requested with the -v option.
The following fields are present in a short listing:
id The index/position of the key in the key ring.
Created
The date the key was created.
Valid after
The date at which the key becomes valid (in other words, the point at which the WebAuth server will start using it to encrypt and
decrypt new data).
Fingerprint
The MD5 digest of the key data. Used to compare keys in two key rings.
The following fields are present in the long listing:
Key-Id
The index/position of the key in the key ring.
Created
The date the key was created.
Valid-After
The date at which the key becomes valid (in other words, the point at which the WebAuth server will start using it to encrypt and
decrypt new data).
Key-Type
The type of key. Currently, AES is the only supported key type.
Key-Size
Length in bytes of the key.
Fingerprint
The MD5 digest of the key data. Used to compare keys in two key rings.
remove id
Remove the key with ID id from the key ring.
EXAMPLES
Add a key to the keyring valid as of the current time:
wa_keyring -f keyring add 0d
Add a key to the keyring that will be valid three days from now:
wa_keyring -f keyring add 3d
Remove keys from the key ring that became invalid more than 90 days ago:
wa_keyring -f keyring gc -90d
Remove the first key in the keyring.
wa_keyring -f keyring remove 0
Display a verbose listing of all of the keys in the key ring:
wa_keyring -f keyring -v list
Note that a WebAuth server will normally manage its keyring file by itself, and wa_keyring is normally only used for debugging purposes.
However, if you are setting up a load-balanced pool of servers that need to all share the same keys, turn off automatic keyring handling by
putting the line:
WebAuthKeyringAutoUpdate off
to your Apache configuration, running a script periodically from cron on one server that does something like:
wa_keyring -f keyring gc -90d
wa_keyring -f keyring add 2d
and then copying (in a secure manner!) the new keyring file to all of the other servers.
AUTHOR
Roland Schemers <schemers@stanford.edu>
4.1.1 2012-04-25 WA_KEYRING(1)