空格坏事儿
[root@server4 ~]# alias hello = 'echo hello'
-bash:alias:hello:not found
-bash:alias: =:not found
-bash:alias: echo hello:not found
[root@server4 ~]# alias hello='echo hello'
[root@server4 ~]# hello
hello
[root@server4 ~]# hello
hello
查看当前用户下的别名:
[root@server4 ~]# cat ~/.bashrc # .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
取消hello的别名:
[root@server4 ~]# unalias hello
[root@server4 ~]# hellobash:hello: command not found...
4.密码隐藏
[root@server4 ~]# cat test4.sh#!/bin/bashecho-e"Enter password:"
stty -echo #这是什么???read password
stty echoechoecho"The password your input is $password"
[root@server4 ~]# sh -x test4.sh
+ echo-e'Enter password:'
Enter password:
+ stty -echo
+ read password
+ stty echo
+ echo
+ echo Password read.
Password read.
[root@server4 ~]# ./test4.sh
Enter password:
Password read.
[root@server4 ~]# vi test4.sh
[root@server4 ~]# ./test4.sh
Enter password:
The password your input is 123456
4.调试脚本
[root@server4 ~]# cat test7.sh #!/bin/bashfor i in {1..6}
doset -x
echo$idoneecho"script executed"
调试脚本
[root@server4 ~]# sh -x test7.sh
+ for i in'{1..6}'
+ set -x
+ echo11
+ set +x
+ echo22
+ set +x
+ echo33
+ set +x
+ echo44
+ set +x
+ echo55
+ set +x
+ echo66
+ set +x
script executed
执行脚本
[root@server4 ~]# ./test7.sh
+ echo11
+ for i in'{1..6}'
+ set -x
+ echo22
+ for i in'{1..6}'
+ set -x
+ echo33
+ for i in'{1..6}'
+ set -x
+ echo44
+ for i in'{1..6}'
+ set -x
+ echo55
+ for i in'{1..6}'
+ set -x
+ echo66
+ echo'script executed'
script executed