Listing 9: prog5
:
#######################################################
# prog5 - list linked files. There are 3 programs
# below.
# 1) list all linked files,
# 2) list files with 5 or more lines, and
# 3) list number of linked files by user.
# see also mklist
masterlist=/usr/stevei/c/stat/master.list
#----------------------------------
# part 1
#----------------------------------
# list all linked files
cat $masterlist |
egrep -v '^d' | # skip directories
awk '{
if ( $4 > 1 )
print
}'|
sort +1bn -y
exit 0
#----------------------------------
# part 2
#----------------------------------
# list files with 5 or more links
cat $masterlist |
egrep -v '^d' | # skip directories
awk '{
if ( $4 >= 5 )
print
}'|
sort +1bn -y
exit 0
#----------------------------------
# part 3
#----------------------------------
# list number of linked files by user.
cat $masterlist |
egrep -v '^d' |
awk '{
if ( $4 < 2 )
next
user[ $5 ] ++
}
END {
printf(" Number of linked files\n")
printf(" user links\n")
printf("---------- -----\n")
for (i in user)
printf("%10s %5d\n", i, user[ i ])
}'
exit 0
|