#!/bin/bash
#
# lastline_of
#
# letzte Zeile einer Datei extrahieren
# Wenn die Datei gepackt ist, dann wird sie entpackt (.gz und .bz2)
##############################################################################
#
if [[ $# -ne 1 || ! -f "$1" ]]
 then
  echo "usage: `basename $0` <file>"
  exit 1
fi
#
if [[ "${1##*.}" = "gz" ]]
 then
  gunzip -c "$1" | tail -1
elif [[ "${1##*.}" = "xz" ]]
 then
  unxz -c "$1" | tail -1
elif [[ "${1##*.}" = "bz2" ]]
 then
  bunzip2 -c "$1" | tail -1
else
  tail -1 "$1"
fi
