UNIX Shell Script
出自KMU Wiki
(修訂版本間差異)
| 在2008年5月6日 (二) 19:14所做的修訂版本 (編輯) Cch (對話 | 貢獻) (新頁面: ==Bourne shell(sh)== === Variable === YOURVAR=some echo $YOURVAR echo ${YOURVAR} === Flow control === if [ -f your_file ]; then echo "your_file exists" fi for f in a b c ...) ←上一個 |
在2008年5月6日 (二) 19:16所做的修訂版本 (編輯) (撤銷) Cch (對話 | 貢獻) 下一個→ |
||
| 第1行: | 第1行: | ||
| - | ==Bourne shell(sh)== | + | == Bourne shell(sh) == |
| === Variable === | === Variable === | ||
| - | + | <pre>YOURVAR=some<br>echo $YOURVAR<br>echo ${YOURVAR}<br></pre> | |
| - | + | <br> | |
| - | + | ||
| - | + | ||
| - | + | ||
| === Flow control === | === Flow control === | ||
| - | + | <pre>if [ -f your_file ]; then<br> | |
| - | + | echo "your_file exists"<br> | |
| - | + | fi<br></pre> | |
| - | + | <br> | |
| - | + | <pre>for f in a b c<br>do<br> | |
| - | + | echo $f<br> | |
| - | + | done<br></pre> | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| === Sub Program === | === Sub Program === | ||
| - | + | <pre>sub()<br>{<br> echo $1 $2 $3<br>}sub X Y Z<br></pre> | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| === Examples === | === Examples === | ||
| + | <pre>#!/bin/sh <br>exec < $1<br>while read line <br>do<br> | ||
| + | echo $line<br> | ||
| + | done<br></pre> | ||
| - | + | == C Shell == | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | ==C Shell== | + | |
在2008年5月6日 (二) 19:16所做的修訂版本
目錄 |
Bourne shell(sh)
Variable
YOURVAR=some<br>echo $YOURVAR<br>echo ${YOURVAR}<br>
Flow control
if [ -f your_file ]; then<br> echo "your_file exists"<br> fi<br>
for f in a b c<br>do<br> echo $f<br> done<br>
Sub Program
sub()<br>{<br> echo $1 $2 $3<br>}sub X Y Z<br>
Examples
#!/bin/sh <br>exec < $1<br>while read line <br>do<br> echo $line<br> done<br>
