📄 addperson
字号:
#!/bin/sh # Name: addperson # Desc: add a person addressbook # Args: -n <name> # -e <email> # -a <postal address> # -p <phone number> # initialize the variables PATH=/bin:/usr/bin MYADDRESSBOOK=./addressbook NAME="" EMAIL="" ADDR="" PHONE="" # create a function to remove the : from user input remove_colon() { echo "$@" | tr ':' ' ' ; } if [ $# -lt 1 ] ; then # this is interactive mode # enable erasing input stty erase '^?' # prompt for the info printf "%-10s " "Name:" ; read NAME printf "%-10s " "Email:" ; read EMAIL printf "%-10s " "Address:" ; read ADDR printf "%-10s " "Phone:" ; read PHONE else # this is non-interactive mode # initialize a variable for the usage statement USAGE="`basename $0` [-n name] [-e email] [-a address] [-p phone]" # scan the arguments to get the info while getopts n:e:a:p:h OPTION do case $OPTION in n) NAME="$OPTARG" ;; e) EMAIL="$OPTARG" ;; a) ADDR="$OPTARG" ;; p) PHONE="$OPTARG" ;; \?|h) echo "USAGE: $USAGE" >&2 ; exit 1 ;; esac done fi NAME="`remove_colon $NAME`" EMAIL="`remove_colon $EMAIL`" ADDR="`remove_colon $ADDR`" PHONE="`remove_colon $PHONE`" echo "$NAME:$EMAIL:$ADDR:$PHONE" >> "$MYADDRESSBOOK" exit $?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -