Created
March 30, 2020 08:21
-
-
Save windard/3c9bb3e0b88903b61d48feb068c07e30 to your computer and use it in GitHub Desktop.
args.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
msg1='$' | |
echo "Shell本身的PID(ProcessID)" | |
printf "The ${msg1}$ is %s\n" "$$" | |
echo "Shell最后运行的后台Process的PID" | |
printf "The ${msg1}! is %s\n" "$!" | |
echo "最后运行的命令的结束代码(返回值)" | |
printf "The ${msg1}? is %s\n" "$?" | |
echo "使用Set命令设定的Flag一览 " | |
printf "The ${msg1}- is %s\n" "$-" | |
echo | |
echo "参数相关,直接运行脚本 ./args.sh 或者 sh args.sh 结果一致" | |
echo '所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。 ' | |
printf "The ${msg1}* is %s\n" "$*" | |
echo '所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。' | |
printf "The ${msg1}@ is %s\n" "$@" | |
echo "添加到Shell的参数个数 " | |
printf "The ${msg1}# is %s\n" "$#" | |
echo "Shell本身的文件名 " | |
printf "The ${msg1}0 is %s\n" "$0" | |
echo "shell 第一个参数" | |
printf "The ${msg1}1 is %s\n" "$1" | |
echo "shell 第二个参数" | |
printf "The ${msg1}2 is %s\n" "$2" |
Author
windard
commented
Mar 30, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment