导言
- #!/bin/bash #sample 1 默认
- ... "#!行"制定的解释器必须用绝对路径;
- ---------------------------------------
- #! /bin/bash -x #sample 2 传递参数
- ... #shell按照/bin/bash -x 执行
- #!/bin/awk -f #sample 3 引用awk解释器
- awk code here
- ---------------------------------------
- #! /usr/bin/perl -w #sample 4 引用perl解释器
- perl code here
- #! /bin/csh -x #csh执行
- md5sum /proc/$$/exe #内置变量$$可以得到本进程id
- ---------------------------------------
- #1dbb32aa0dd6b341155d05ea564c2c4a /bin/csh的md5
- #a43f08494674e2da1a8e3547d0991e88 /bin/bash的md5
- $ ./interpreter.sh
- md5sum /proc/32623/exe
- 1dbb32aa0dd6b341155d05ea564c2c4a /proc/32623/exe #csh的md5
- $ bash interpreter.sh
- a43f08494674e2da1a8e3547d0991e88 /proc/30407/exe #bash的md5
- #!/bin/bash - #空选项
- shell code here
- 内置变量$$可以得到所在进程的pid
- #! - 可以防止某些脚本攻击行为