Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Write a bash script named oldest that accepts a directory name as a command line argument and then looks at all of teh files in that directory to find the oldest file. Print out the name fo teh file adn teh age of that file in days. If no directory name is listed on the command line, perform the check on the current directory. This is what i have. Can you please help me.

while (*)
$age = -M
fi [ oldest_age -lt $age && $oldest_name -eq $_ && oldest_age -eq $age ]; then
echo "The oldest file is $oldest_name and is $oldest_age days old. "
 
break your problem down into steps and crack each, one by one

1 - how to get a list of files in a directory
2 - how to do something with that list (just print it to startp)
3 - how to get the age of a file (that's not strictly possible, by the way, you can get the age of the *name* of that file, which might be different if it's been renamed)
4 - how to compare the ages of files

or maybe there's a command that will list files in timestamp order - is there a command to list files on a unix system? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
how can I recieve last mail to a file?
merci.
is it
mail > file
?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top