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 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