Cover V03, I03
Article
Figure 1
Figure 2
Listing 1
Listing 10
Listing 11
Listing 12
Listing 13
Listing 14
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

may94.tar


Listing 6: prog3

:
#######################################################
# prog3 - list the 10 oldest (or newly created) files,
# by user.  sort in reverse order to list the newest.
#######################################################

# see also mklist
find / -type file -print |
stat -idmMupsn - |
awk '{
inum=$1
device=$2

# the [constructed] idnum must be used when scanning
# multiple file systems in order to uniquely
# identify the file.

idnum=sprintf("%s %s", inum, device)

uid=$3
fsize=$4
day=$5
month=$6
dayofmonth=$7
time=$8
year=$9
access=sprintf("%s %s %s %s %s",
day, month, dayofmonth, time, year)

Atime=$10
fname=$11

# do not recount linked files

if ( unique[ idnum ] != 1 )
printf("%8s %s %10d %s %s\n", uid,
Atime, fsize, access, fname)
unique[ idnum ] = 1
}' |
sort |
# use the -r flag to list the newest instead of the
# oldest.
# sort -r |
awk 'BEGIN {
max_count=10 # list only 10 files for each user
count=1
}
{
cur_id=$1
if ( cur_id == last_id )
count += 1
else
count=1

if ( count < max_count )
print

last_id=cur_id
}'
exit 0