Shell Scripting
Unix Shell Family tree
Thompson Shell 1971
|_ Bourne (sh) 1977 관리자 기능에서 유용했음
|_ Korn (ksh) 1983 csh과 ksh의 장점 믹스
|_ Korn (ksh93) 1993 이 때 POSIX Shell이 HPUX의 표준이됨
|_ Bourne-Again (bash) 1987
|_ Cshell (csh) 1978 자동 완성기능 등 프로그래머들 유용한 커맨드 많음
Which Shell Interprects the Script? Hash #, bang ! and absolute path
#!/usr/bin/sh Interpret using the POSIX Shell
#!/bin/sh Interpret using the POSIX Shell ...
#!/bin/csh ... C Shell...
Recommended Script Format
First Line - Specify the interpreter
Header - Brief description of the script
Body - Commands to be executed
Last Line - exit# , # is return value
How HP-UX Uses Shell Scripts
1 At system start-up(boot) time
2 At system shutdown
3 As commands
실습
1
$ vi sysinfo.sh
"sysinfo.sh" 1 line, 45 characters
echo "hostname of this machine: $(hostname)"
print "Operating system : $(uname -s)"
print "OS version: $(uname -r)"