Shell Script 1.1

Source: Internet
Author: User

#环境变量
Echo $HOSTNAME #主机名
Echo $SHELL #目前用的哪个解释器
Echo $PATH #命令搜索路径
Echo $USER #使用的哪个用户
Echo $PWD #当前目录
Echo $HOME #家目录是哪个
Echo $LOGNAME #哪个用户


# positional variables
Echo
echo $
Echo
echo $
Echo $* #显示所有位置值
Echo $# #显示位置值的总数量

echo $$ # Process number PID of the current process

echo $? #判断上一条是否成功, 0 successful, others are unsuccessful

Echo $! #Shell最后运行的后台进程的PID

#特殊符号
"$ABC" #双引 (Reference whole)
' $abc ' #单引 (reference whole, special symbol does not work)
' Date +%y%n%d ' #反引 (Put the executable command, return the result of the command) $ (date) = ' Date '
{variable name} parameter #{} is the variable name, and if not, echo ${a}b may not be recognized

#read配置
READ-P "hint Information" variable name #定义变量名, but does not give value
Useradd $ variable Value #给变量值
-S #输入的数值不可见
-T 3 #设置时间秒, null value exceeded
-N 3 #设置字符数量, achieves immediate execution

#历史命令使用
History
!cat #执行cat开头的最近那条历史命令
!100 #执行第100条历史命令

Stty Echo #开启显示
Stty-echo #关闭显示

Export variable #将局部变成全局 (define system variable) global variable best capitalization
Export-n variable name #取消全局属性 local variable preferably lowercase

Env #列出环境变量
Set #列出所有变量
Unset #取消定义的变量

#脚本执行3种方式
./Script
Bash script
The document where the source script resides

Shell Script 1.1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.