Online Resources: http://tldp.org/LDP/abs/html/...
set -e
Exit the script if an error happens
圆括号
括号中的命令将会新开一个子shell顺序执行:
(bar="hello world") echo $bar # 无输出
&&
&& lets you do something based on whether the prevIoUs command completed successfully
$ true && echo "Things went well" Things went well $ false && echo "This will always run"
Internal Variables
http://tldp.org/LDP/abs/html/...
$PATH,${PATH}: Path to binaries
$PWD,${PWD}: Working directory (directory you are in at the time)
Internal Commands
1. export:
http://blog.51cto.com/beyond3...
export command is used to export a variable or function to the environment of all the child processes running in the current shell.
a.sh
#!/bin/sh echo "$foo" echo "$bar"
b.sh
foo="hello world" bar="hello" export foo ./a.sh
等价于==>
bar="hello" foo="hello world" ./a.sh
2. source 或 点操作符"."
imports code into the script
# import utils . scripts/utils.sh source scripts/utils.sh
External Commands
In general,an external command in a script forks off a subprocess,whereas a Bash builtin does not. For this reason,builtins execute more quickly than their external command equivalents.Basic commands: ls,cat,rm,...
原文地址:https://www.jb51.cc/bash/387939.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。