#!/bin/sh # to view tar's usage() { printf '%s\n' 'USAGE'\ ' trq ARCHIVE (FILE)?'\ ' trq - (FILE)?'\ 'WHERE'\ ' ARCHIVE is the archive to inspect.'\ ' - reads from standard-input'\ ' FILE is a file path.' exit 1 } C=false while [ $# -gt 0 ]; do case "$1" in *) break ;; esac; done [ $# -lt 1 ] &&usage F="$1" &&shift 1 if [ $# -gt 0 ]; then tar -xOf "$F" "$1" else tar -tf "$F" fi