#!/bin/sh if [ $# -eq 0 ]; then fn='-' elif [ $# -eq 1 ]; then fn="$1" else echo "usage: shwc [ file ]" >&2 exit 1 fi cat $fn | awk 'BEGIN { nl = 0; nw = 0 } { nl++ ; nw += NF } END { print "Lines:", nl, "words:", nw }'