Shell Script Seminar - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Shell Script Seminar

Description:

... sparcs source test . 4.1 How to make and run Shell script ... Berkeley UNIX C Shell ... c command, d ... – PowerPoint PPT presentation

Number of Views:141
Avg rating:3.0/5.0
Slides: 25
Provided by: ASHI61
Category:

less

Transcript and Presenter's Notes

Title: Shell Script Seminar


1
Shell Script Seminar 1999 Spring, SPARCS
by ???(ari_at_sparcs.kaist.ac.kr)
2
- Contents -
1. What's a Shell ? 2. What's a Shell Script
? 3. Why we use a shell script ? 4. Bash and
Shell script 5. Tcsh and Shell script 6.
Environment variables
3
1. What's a Shell ?
- ??? ?? ??? ????? - GUI - ??? ?? ????? - ??
- ?????? ????? - ???? ?? ??? ???? - Windows?
???? ???? explorer?? ?? ?? ? ???, ??? ????
??? ?? ????? ????? ?? ??? ??.
4
2. What's a Shell script ?
- MS-DOS ? ????(Batch File)? ????. - ????? ?? (
??? ??? ?????) - ? ????? ??? ???? ??? ???,
?? ?? ??? ???? ??? ?? ???. - ?? ???? ?? ????
(???? !/bin/bash ? ??)
5
3. Why we use a shell script ?
- ???? ??? ?? ?? ??? - ?? ??? ? ??? ??? ??? -
???? - .tcshrc .bashrc .muttrc .vimrc .xsession
- ? ????? ??? ??? ????.
6
4. Bash and Shell script
- ??? FSF(GNU)?? ???? Bourne Shell? ??? ??
??? Bourne Again Shell? ????. - ??? ??? ?? ????,
C ?? ??? ?? ????. - ???? ??? ??? ?? ??? ??
??? ????. - .bashrc ?? ?? bash? ??? ?? ???,
?? ?? ??? set? env? ??? ?? ??? ?? ? ? ??.
7
4.1 How to make and run Shell script ?
- !/bin/bash? VI?? ???? ????? ???? ???. -
sparcsgt bash filename - ???? ?? ?? ???? ?????.
- ?? ??? (rwx?? x)? ?? ??? ??. ? ????? ????
??? ?? ??? ???, ?? ??? ???? ???. - ?? ???? ??
?? sparcsgtfilename ???? ????. - ? ???? ?? ?????
? ???? ???? ????. (for, if ?? ??? ??..) -
sparcsgt source test ? ?? ????? ???? ? ??.
8
4.2 Variable
- sparcsgt var1ABCDE sparcsgt echo var1 (
echo "var1") ABCDE - sparcsgt var1
(?? ????? ?? ???..) sparcsgt echo var1
Mail News documents public_html test1 test2 test3
sparcsgt echo "var1" - sparcsgt var1t
(t? ???? ?? ???..) sparcsgt echo var1
test1 test2 test3
9
4.3 If-then
- if ?? then ?? ? ? ? fi - if ??
then ?? ? ? ? else ??? ? ? ?
fi - if ??1 then ??1? ?? ? ? ?
elif ??2 then ??2? ?? ? ? ? fi
10
4.4 For, while
- for I in 1 2 3 4 5 6 7 8 9 10 do echo I
done - while ?? do ? ? done
11
5. Tcsh and Shell script
- Tcsh? Berkeley UNIX C Shell(csh)? ????
????, ??? ?? ??? completion? ??? ???. - ??
????? C??? ??? ?? ???, C? ????? ???? ??? ??
??. (??? ???) - !/bin/tcsh? ??? ???? ????, ????
??? tcsh filename?? ????.
12
5.1 Variable
- sparcsgt set var1ABCDE (set? ??? ?? ??
!) sparcsgt echo var1 12345 - sparcsgt set
var1(ABC, DEF, GHI) sparcsgt echo var3
GHI sparcsgt echo var2-3 DEF GHI -
sparcsgt _at_ a 12345 (????? ?? _at_?
???. sparcsgt echo a _at_? ???
??? ??? ??) 12345
13
5.2 Operator Calculation
- c? ?? ???? ??? ? ? ??. - sparcsgt _at_ a 5
sparcsgt _at_ b 3 sparcsgt _at_ ca b
(? c?? ??? ????) 2 - ? ??? , -, , /, gtgt,
ltlt, , , -, --, , /, ?? C ???? ? ?
??.
14
5.3 Foreach, while
- test?? !/bin/tcsh foreach X ( ABC DEF
GHI JKL MNO ) echo X end -
sparcsgt tcsh test - while ( ?? ) ? ? end
15
5.4 If-then
- if ??? C? ???? ???. - if ( case ) do
something - ex) if ( ?a1 ?b1 ) echo
ABCDE
16
6. Environment Variables
- ?????? path, prompt, alias, complete ??? ?? -
??? ??? ??? ? ??? ???? ?? ??? ?? ??.
6.1 History
- ???? ?? C??? ????. ???, ???? ???? ??.
17
6.1.1 History of bash
- sparcsgt set HISTFILE/home98/ari/.ba
sh_history HISTFILESIZE500 HISTSIZE500 -
???? ??? .bash_history?? ?? ???? 500, ????
???? ???? 500?? ???? ??? ????.
6.1.2 History of tcsh
- sparcsgt set history 100 - ???? ???? 100??
????
18
6.1.3 Usage of History
- sparcsgt !! ?? ??, ?? ?? ???? ??? ?? ?? -
sparcsgt !10 ??? ??, history? ??? ???? ???
10?? ??? ????. - sparcsgt !-10???
??, 10?? ?? ???? ??? ?? - sparcsgt !a ?? ?? a?
???? ?? ??? ??? ??
19
6.2 Alias
- alias ls 'ls -p --colortty 1 -F' - sparcsgt
ls ?? ?? ??? ls -p --colortty -F? ????. -
sparcsgt ls -la ? ls -p --colortty -la -F? ????.
- ??? alias ??? ?????? alias? ?????? ? ? ??.
20
6.3 Complete
- Completence? ???? ??? tab? ??? ?, ?? ???
???? ???? ??? ????? ????. (tab?? D ? ????) -
List ??? ??? ?? ??? ???? ?, ????? ?? ?. ? ???
set autolist? ?? ?? ?? ? ? ??. - sparcsgt cd
tab Mail/ News/ digital/
documents/ public_html/ sparcsgt cd -
sparcsgt cd dtab digital/ documents/
sparcsgt cd d - sparcsgt talk tab ari
bxxxxxx gxxxxxxx ixxxx vxxx sparcsgt talk
21
- sparcsgt talk artab (?? ??? ???) sparcsgt
talk ari - ?? ?? ??? ?? ????? ?? Complete ??. -
sparcsgt atab? ?? ?? ??? path?? a? ???? ??
???? ????. - sparcsgt man tab? ?? ????? ???
???. - sparcsgt finger tab? ?? ????? ??? ???.
- ?? ??? complete?? ??? ?????? complete?
????. - set fignore(.bak .xxx)? ?? ?? ?? ??,
.bak ?? .xxx? ??? ???? complete list?? ????
???. - .tcshrc?? ?? complete?? ???? ??. ?)
complete cd p/1/d/ complete man p/1/c/
22
- complete ? ??? complete ??? ??1/??/??2/??? -
??1? c, C, n, N, p? ? ? ??? ??1? ??? ???? ???
????. - ??2? a, c, d, f, s, u ?? ???, a? alias,
c? command, d? directory, f? ??, s? set, u?
user? ????. - ???? ??? ??, ??? ?? ??? 1?? ?, ?
complete ? ? ? ?? ??? ???? ????. - complete
set 'c//f/' 'p/1/s/' 'n//f' ?? ?? ? ??? ????
??? ?? ??? complete ??? ??. - ?? 1? c? n? ???
c? ??? ???? ??, n? ??? ??? ??? ?? ??? ????.
23
- ?? 1? p? position? ???? ???, 1? tab? ??
??? ??? ???? ??????? ???. p//... ? ?? ?? ???,
??? ???? ???? ????. ??? ?? ??? ???? ? ???
??. - sparcsgt set tab? ?? p/1/s/? ????
complete? ?? - sparcsgt set argtab? ?? ??
p/1/s/? ????, set??? arg? ???? ?? argv ??
???. ??? ?? ? ??. sparcsgt set argv -
sparcsgt set atab? ??, c//f/? ???? complete?
?? - sparcsgt set a itab? ??, n//f/? ????
complete? ??
24
6.4 Prompt
- set prompt "m " ? ?? ???? ???. - prompt?
""?? ??? ? ?? ???? ??? ??. - /, ?? ????.
? home98/ari? ? ????. - h, ! History ??
- M, m ??? ?? m? ? ?? . ???? ????. -
?? - t, T, _at_, p, P ?? ?? (?? ??? ??) -
n ??? ?? - d, D, y, Y, w, W ??, ?, ?,
- gt??
Write a Comment
User Comments (0)
About PowerShow.com