[net.sources] fixhist.sh - fix the B news history file - see mkhistory.c

solomon (03/26/83)

#!/bin/sh
# Fix /usr/lib/news/history to truncate names in it to 14 characters, so
# that it will be directly comparable to the output of mkhistory for
# the sake of comparison.  Also sort the list of file names on each line.
awk '
BEGIN { FS = "\t" }
{
	nfiles = split($3,fnames," ")
	printf "%s\t%s\t", $1, $2
	for (i=1;i<=nfiles;i++) {
		slash = index(fnames[i],"/")
		if (slash <= 14)
			name[i] = fnames[i]
		else
			name[i] = substr(fnames[i],1,14) substr(fnames[i],slash)
	}
	if (nfiles==1) printf "%s ",name[1] # special case for efficiency
	else
		while (nfiles > 0) {
			pos = 1
			for (i=2;i<=nfiles;i++)
				if (name[i]<name[pos]) pos = i
			printf "%s ",name[pos]
			for (i=pos+1;i<=nfiles;i++) name[i-1] = name[i]
			nfiles--
		}
	printf "\n"
}' </usr/lib/news/history