#!/bin/sh -e
#
# trim - trim trailing whitespace from input's each line.
# awk '{$1=$1};1'

# check to see if a pipe exists on stdin.
if [ -p /dev/stdin ]; then
  # if we want to read the input line by line
  while IFS= read -r line; do
    echo "${line}" | awk '{$1=$1};1'
  done
elif [ "$#" -gt 0 ]; then
  echo "$@" | awk '{$1=$1};1'
fi
