您的位置:首页 > 运维架构 > Shell

linux shell scripts

2009-01-10 21:52 344 查看
命令替换和输出捕获 `command` $(command), $()是posix shell的标准, `command`是bash shell的标准。

hard quote 单引号中的所有字符都不被shell解析, soft quote 双引号,部分字符还是会被shell解析(如$), escape / 紧接在反斜线后面的字符是不被shell解析。

fork source exec。挡在command line(主shell)中键入 ./test.sh时,test.sh是以fork方式运行,也就是在sub-shell(子进程)中运行,任何在sub-shell中改变的环境变量只在sub shell中有效对父shell是无效的,除非用export var使其在父 shell中生效。 当以 souce ./test.sh(与. ./test.sh等价,.意味着在本shell中运行)运行时,test.sh是在父shell中运行 ,因此任何在test.sh做的改变都在父shell中生效。exec ./test.sh意味着 test.sh覆盖了父shell。

2)字符串
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: