Shell脚本的选项解析getopts

getopts option-string var

getopts对命令行中给出的选项进行解析的步骤

使用getopts 先写一个脚本来简化对文件的uuencode流程

uuencode这个脚本其实是一个最早用来将二进制文件(可执行文件)编码成ASCII文本的程序。。。

#!/bin/sh

USAGE="Usage: 'basename$0' [-v] [-f] [filename] [-o] [filename]";
VERBOSE=false

while getopts f:o:v OPTION;
do
	case "$OPTION" in
		f) INFILE ="$OPTARG";;
		o)
		v)
		\?)
	esac
done

shift 'echo "$OPTOND -1" | bc'

...

这里没有写全。

原文地址:https://www.cnblogs.com/junzhkevin/p/2198906.html