utils upgrade
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [-h] <lineno> <file>
|
||||
|
||||
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
|
||||
sed -n "${lineno}p" -- "$@"
|
||||
|
||||
if [[ ! -t 0 ]]; then # Read from stdin (pipe)
|
||||
sed -n "${lineno}p"
|
||||
else # Read from file
|
||||
sed -n "${lineno}p" -- "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user