#!/usr/bin/env bash set -eo pipefail if [[ "$1" == "-h" || "$1" == "--help" ]]; then cat < Display a specific line from a file. Options: -h, --help Show this help message Arguments: lineno Line number to display (1-based) file File to read from EOF exit 0 fi lineno="$1"; shift if [[ ! -t 0 ]]; then # Read from stdin (pipe) sed -n "${lineno}p" else # Read from file sed -n "${lineno}p" -- "$@" fi