#!/bin/sh
##################################################################
#		O N C E
#		-------
# Description:
#	Print same lines only once. This is different from
#	sort -u which also sorts the data, this show the first
#	line first but not several times.
#
# Usage:
#	once [-r] 
#
# Copyright (C) 1997  Lars Berntzon
#
##################################################################

#
# Reverse the data.
#
if [ "$1" = -r ] ; then
    $AWK '{
    line[i++] = $0;
}
END{
    while(i-- > 0) {
    	print line[i]
    }
}'
else
    cat
fi | $AWK '{
    if (count[$0]++ == 0) {
    	print
    }
}'
