#!/bin/bash # bash a.sh p1 p2 # print the first argument echo $1 # p1 # print all arguments echo $@ # p1 p2 echo $* # p1 p2 # print number of arguments echo $# # 2
#!/bin/bash #bash a.sh -u lchen -f dat while getopts u:f: option do case "$option" in u) U=${OPTARG};; f) F=${OPTARG};; esac done echo $U # lchen echo $F # txt