ex14.sh
来自「一本完整的描述Unix Shell 编程的工具书的所有范例」· Shell 代码 · 共 44 行
SH
44 行
#!/bin/bash# zmore#View gzipped files with 'more'NOARGS=65NOTFOUND=66NOTGZIP=67if [ $# -eq 0 ] # same effect as: if [ -z "$1" ]# $1 can exist, but be empty: zmore "" arg2 arg3then echo "Usage: `basename $0` filename" >&2 # Error message to stderr. exit $NOARGS # Returns 65 as exit status of script (error code).fi filename=$1if [ ! -f "$filename" ] # Quoting $filename allows for possible spaces.then echo "File $filename not found!" >&2 # Error message to stderr. exit $NOTFOUNDfi if [ ${filename##*.} != "gz" ]# Using bracket in variable substitution.then echo "File $1 is not a gzipped file!" exit $NOTGZIPfi zcat $1 | more# Uses the filter 'more.'# May substitute 'less', if desired.exit $? # Script returns exit status of pipe.# Actually "exit $?" is unnecessary, as the script will, in any case,# return the exit status of the last command executed.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?