Pete's Linux Advent Calendar 2007

The 18th day

What is the oldest file on your system?

Here is one way to answer that question:
#! /bin/bash

oldest_file=""

while read file; do
    if [ ! -f "$file" ]; then
        continue
    fi
    if [ -z "$oldest_file" ]; then
        oldest_file="$file"
        continue
    fi

    if [ "$file" -ot "$oldest_file" ]; then
        oldest_file="$file"
    fi
done < <(find ${*:-.} -type f)

ls -l "$oldest_file"

Pete's Linux Advent Calendar 2007

Valid HTML 4.01!

Comments? send mail to pkruse@arcor.de my monogram