ebook 99-1

Similar documents
ebook 99-9

ebook 99-11

投影片 1

Unix®t Œ fi z.PDF

Microsoft Word - linux命令及建议.doc

本文由筱驀釹贡献

PowerPoint 演示文稿

Bourne Shell及shell编程

ebook35-2

ebook15-C

ebook70-22

ebook70-21

第零章、為何要學作業系統

Microsoft Word - PS2_linux_guide_cn.doc

Linux服务器构建与运维管理

ebook70-5

Linux Ubuntu Part Linux Ubuntu Linux UNIX...19 Linux...19 Linux Linux...21 Linux GNU FSF Open So urce.

I B :

Linux操作系统使用

第 4 章 Linux shell 程序设计 shell UNIX/Linux Linux shell shell if case while for shell Linux Linux 本章主要介绍 Linux shell( 默认是 bash) 的语法结构 变量定义及赋值引用 标点符号 控制语句等

epub 73-5

lect03.ppt

像 客 样 使 命令行 徐 东

投影片 1

ebook70-14

ebook70-11

ebook62-1

Microsoft Word - 第5章.doc

ebook65-20

292 shell shell C shell ~/.cshrc shell ~/.login ~/.logout ~/.history.cshrc shell shell /etc/passwd ~name NIS NIS+ * 0? [abc...] a-za-z0-9

PowerPoint プレゼンテーション

TX-NR3030_BAS_Cs_ indd

Untitled

05_資源分享-NFS及NIS.doc

f2.eps

Microsoft Word - 國文.doc

WWW PHP

Lorem ipsum dolor sit amet, consectetuer adipiscing elit

Microsoft PowerPoint - 第7章 Linux基本命令

目 录 目 录 1. 安 装 和 快 速 入 门 附 件 1.1 随 机 附 件 附 件 信 息... 3 连 接 和 设 定 1.3 连 接 记 录 纸... 4 快 速 入 门 1.5 发 送 传 真 / 复 印 接 收 传 真

mannal

ebook

Linux 操作系统课程社区创作

Abstract arm linux tool-chain root NET-Start! 2

基本概念

untitled

untitled

epub 61-2

目 錄 壹 青 輔 會 結 案 附 件 貳 活 動 計 劃 書 參 執 行 內 容 一 教 學 內 容 二 與 當 地 教 師 教 學 交 流 三 服 務 執 行 進 度 肆 執 行 成 效 一 教 學 課 程 二 與 當 地 教 師 教 學 交 流 三 服 務 滿 意 度 調 查 伍 服 務 檢

Linux 目 录 结 构 与 Windows 将 硬 盘 看 做 C 盘 D 盘 几 个 独 立 的 分 区 不 同,Linux 将 整 个 文 件 系 统 看 做 一 棵 树, 这 棵 树 的 树 根 叫 做 根 目 录, 用 / 表 示 各 个 分 区 通 过 挂 载 (mount) 到 文

PowerPoint Presentation

Cygwin & vim

untitled

Solaris ( ) Solaris Shell awk gawk vi emacs OK mode 1

Shell

ebook4-附录C

ebook8-30

ebook 134-6

Guide to Install SATA Hard Disks

2004 Sun Microsystems, Inc Network Circle, Santa Clara, CA U.S.A. Sun Sun Berkeley BSD UNIX X/Open Company, Ltd. / SunSun MicrosystemsSun

epub 63-3

CCNA 3 Module 5 Switching Concepts

Microsoft Word - template.doc

《计算机导论》实验教学大纲

四川省普通高等学校

WinMDI 28

ebook71-6

Windows XP

Web

ebook140-8

2005 Sun Microsystems, Inc Network Circle, Santa Clara, CA U.S.A. Sun Sun Berkeley BSD UNIX X/Open Company, Ltd. / Sun Sun Microsystems Su

ORACLE Enterprise Linux 6.3下ORACLE11g的安装

電子商業伺服器管理(終極版).doc

KDC-U5049 KDC-U4049 Made for ipod, and Made for iphone mean that an electronic accessory has been designed to connect specifically to ipod, or iphone,

.. 3 N

C/C++程序设计 - 字符串与格式化输入/输出

资源管理软件TORQUE与作业调度软件Maui的安装、设置及使用

例 度 讀 讀 不 不 來 念 來 了 讀 不 不 讀 不 讀行 利 了 說 更 了 讀

陕西省粮食流通

Untitiled

起 初, 距 離 出 版 日 期 還 有 大 半 年, 大 家 雀 躍 萬 分 之 餘 還 滿 盤 大 計, 他 答 應 做 這 樣 她 應 承 安 排 那 樣 你 負 責 做 三 件 事 我 就 辦 兩 件 大 家 都 是 成 年 而 又 自 律 的 人, 一 切 猶 如 入 了 自 動 波, 不

<4D F736F F D20A5FAA9FAAABAB4BCBC7AA15DA440A15EB773A5C1AF5AA1C4B871B8D1A15DB16DA6E2A15E2E646F63>

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2

C/C++ - 函数

2_dvdr3380_97_CT_21221b.indd

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

pdf

CC213

区 域 活 动 进 入 中 班 我 们 区 域 的 设 置 和 活 动 材 料 都 有 所 变 化, 同 时 也 吸 引 孩 子 们 积 极 的 参 与 学 习 操 作 区 的 新 材 料 他 们 最 喜 欢, 孩 子 们 用 立 方 块 进 行 推 理 操 作 用 扑 克 牌 进 行 接 龙 游

Microsoft Word - CP details 2.doc

Bus Hound 5

要 站 立 得 稳, 我 在 十 字 架 上 已 经 都 抢 夺 过 来 了, 将 魔 鬼 不 让 你 们 来 享 用 的 都 推 开 了, 这 是 让 我 们 来 得 到 的 话 语 我 们 再 也 不 被 奴 仆 的 轭 辖 制, 要 来 拥 有 才 可 以 明 知 道 却 不 去 抢 夺 过

第5章修改稿

ebook45-5

ebook71-8

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10

epub83-1

C/C++ - 文件IO


CLP-585/575/545/535/565GP

Transcription:

s h e l l 1 setuid chown c h g r p umask ( ) 1) 2) 3) s h e l l 1) 2) 3) 1.1 i ls -l

2 shell total 4232 - r w x r- x r- x 9 9 r w x r- x r- x r w x 1 root root r o o t ( r o o t ) 3578 K Oct 14 04:44 dmesg 1.2 ls -l d l ( ) s b c p - 1.3 t o u c h $ touch myfile ls -l

1 3 ( ) r w - r- - r a d m i n 1-1 ls -l ( )- ( ) r w - ( ) r- - ( ) r- - ( ) 1) 2) ( ) 3) r w / x m y f i l e - r w - r- - r-- m y f i l e u m a s k ( 1-2 ) 1-2 r-- --- --- r-- r-- --- r-- r-- r- - rwx r-- r- - rwx r-x --- ( )

4 shell rwx r-x r- x rw- rw- --- rw- rw- r- - rw- rw- --- 1.4 ( ) c h m o d 1.4.1 c h m o d chmod [who] operator [permission] filename w h o u g o a ( ) o p e r a t o r + - = p e r m i s s i o n r w x s s e t - I D t * l u,g,o * t t t t ( ) t

1 5 1.4.2 chmod c h m o d m y f i l e r w x rwx rwx chmod a-x myfile rw- rw- rw- chmod og-w myfile rw- r-- r- - chmod g+w myfile rw- rw- r- - chmod u+x myfile rwx rw- r- - chmod go+x myfile rwx rwx r- x m y f i l e ( ) $ chmod u+x o-w myfile m y f i l e a d m i n $ chmod u+x dt 1.4.3 c h m o d chmod [mode] file m o d e 1-3 1-3 / 0 4 0 0 0 0 1 0 0 2 0 0 0 0 0 4 0 1 0 0 0 0 0 2 0 0 4 0 0 0 0 1 0 0 2 0 1-3 1-3 7

6 shell 644 0400 + 0200 ( ) = 0600 0040 ( ) = 0040 0004 ( ) = 0004 0 6 4 4 1-4 1-4 r w x r w x r w x 4 + 2 + 1 4 + 2 + 1 4 + 2 + 1 1-4 m y f i l e r w - r - - r - - 4 + 2 4 4 644 1.4.4 chmod c h m o d chmod 666 rw- rw- rw- chmod 644 rw- r-- r- - chmod 744 rwx r-- r- - chmod 664 rw- rw- r- - chmod 700 rwx --- --- chmod 444 r-- r-- r- - y o a a d m i n chmod 644*

1 7 - R chmod -R 664 /usr/local/home/dave/* / u s r / l o c a l / h o m e / d a v e - R 1.4.5 1.5 c h m o d 1-5 1-6 1-5 r w x 1-6 drwx rwx r- x ( 7 7 5 ) drwx r-x r- - ( 7 5 4 ) drwx r-x r- x ( 7 5 5 ) -- x d o c s p a y a d m i n a d m i n 1.6 suid/guid s u i d g u i d

8 shell s u i d s h e l l g u i d 1.6.1 suid/guid g u i d U N I X s u i d g u i d / b i n / s b i n $ ls -l grep '^...s' s u i d $ ls -l grep '^...s..s' s u i d g u i d s u i d s u i d 4 g u i 2 4+2 s x s u i d g u i d g u i d l o g i n s u i d rwx rw- r-- (741) c h m o d 4 chmod 4741 r w s rw- r- - $ chmod 4741 logit 1.6.2 suid/guid 1-7 s u i d / g u i d chmod 4755 rws r-x r- x s u i d chmod 6711 rws --s --s s u i d g u i d chmod 4764 rws rw- r- - s u i d

1 9 s u i d / g u i d rwx r-x r- x s u i d chmod u+s <filename> rws r-x r-x s u i d rws r-x r- x S s u i d c h m o d chmod 1.7 chown chgrp / e t c / p a s s w d I D s u i d c h o w n chmod -R -h owner file - R - h 1.7.1 chown p r o j e c t l o u i s e p a u l i n 1.7.2 chgrp c h g r p c h o w n p a u l i n e a d m i n s y b a d m i n 1.7.3

10 shell i d 1.7.4 m a t t y s y b a d m i n a p p s g e n p o s t 1.8 umask u m a s k c h m o d u m a s k u m a s k s h e l l u m a s k u m a s k / e t c / p r o f i l e u m a s k u m a s k $ H O M E. p r o f i l e. b a s h _ p r o f i l e 1.8.1 umask u m a s k ( ) u m a s k 6 c h m o d u m a s k 7 umask nnn n n n u m a s k 0 00-777 u m a s k u m a s k u m a s k 1-8 u m a s k u m a s k / u m a s k u m a s k 002 664 7 75 u m a s k u m a s k

1 11 1-8 umask u m a s k 0 6 7 1 6 6 2 4 5 3 4 4 4 2 3 5 2 2 6 0 1 7 0 0 u m a s k 0 02 777 ( ) u m a s k 002 u m a s k 002 1) rwx rwx rwx (777) 2) umask 002 - - - - - - -w- 3) rwx rwx r-x (775) 4) rw- rw- r-- (664) u m a s k 022 1) rwx rwx rwx (777) 2 ) u m a s k 022 - - - -w- -w- 3) rwx r-x r-x (755) 4) rw- r-- r-- (644) 1.8.2 umask 1-9 u m a s k 1-9 u m a s k u m a s k 0 2 2 7 5 5 6 4 4 0 2 7 7 5 0 6 4 0 0 0 2 7 7 5 6 6 4 0 0 6 7 7 1 6 6 0 0 0 7 7 7 0 6 6 0 umask u m a s k

12 shell u m a s k u m a s k $ umask 002 u m a s k u m a s k / u m a s k 600 / 066 1.9 1.9.1 / u s r / l o c a l / a d m i n / s a l e s $ H O M E $ H O M E $ H O M E / u s r / o p t / a p p / l o g ln [-s] source_path target_path 1.9.2 40 $ H O M E. p r o f i l e / u s r / l o c a l / m e n u s / p r o f i l e s a l e s. p r o f i l e a d m i n. p r o f i l e $ H O M E s a l e s. p r o f i l e $ H O M E a d m i n. p r o f i l e t a rg e t _ p a t h l n

1 13 m a t t y ( ) p r o f i l e 40 / u s r / o p t / m o n i t o r / r e g s t a r / v a r / a d m / l o g s $ ln -s /usr/opt/monitor/regstar/reg.log /var/adm/logs/monitor.log 777 rwx rwx rwx / v a r / t m p / v a r / t m p ( ) l n / v a r / t m p / v a r 1.10 chmod -R s u i d s u i d

2 find xargs ( ) F i n d find f i n d f i n d x a rg s f i n d ( N F S ) f i n d f i n d ( 30 G ) F i n d find pathname -options [-print -exec -ok] pathname find. / -print find -exec find s h e l l ' c o m m - and' {} \; {} \ -ok - e x e c s h e l l 2.1 find f i n d - -name -perm -prune f i n d - d e p t h - p r u n e f i n d -user -group -mtime -n +n - n + n n F i n d - a t i m e - c t i m e - m t i m

2 f i n d x a rg s 15 - m t i m e -nogroup / e t c / g r o u p s -nouser / e t c / p a s s w d -newer file1! file2 f i l e 1 f i l e 2 -type b - d - c - p - l - f - -size n[c] n c -depth -fstype / e t c / f s t a b -mount m o u n t -follow f i n d -cpio c p i o 2.1.1 name f i n d $ H O M E *. t x t ~ ' p a t h n a m e ~ $ H O M E $ find ~ -name "*.txt" -print *. t x t $ find. -name "*.txt" -print $ find. -name "[A-Z]*" -print / e t c h o s t $ find /etc -name "host*" -print $ H O M E $ find ~ -name "*" -print find. -print $ find / -name "*" -print *. t x t a x 37. t x t

16 shell $ find. -name "[a-z][a-z][0--9][0--9].txt" -print 2.1.2 perm - p e r m 755 $ find. -perm 755 -print f i n d - p e r m - - p e r 007 c h m o d $ find. -perm -007 -print 2.1.3 - p r u n e - p r u n - d e p t h - p r u n e f i n d / a p p s / a p p s / b i n $ find /apps -name "/apps/bin" -prune -o -print 2.1.4 user nouser $ H O M E d a v e $ find ~ -user dave -print / e t c u u c p $ find /etc -user uucp -print - n o u s e r / e t c / p a s s w d - n o u s e r f i n d / h o m e $ find /home -nouser -print 2.1.5 group nogroup u s e r n o u s e r f i n d / a p p s a c c t s $ find /apps -group accts -print n o g r o u p f i n d $ fine/-nogroup-print

2 f i n d x a rg s 17 2.1.6 m t i m e m t i m e n + n 5 $ find / -mtime -5 -print / v a r / a d m 3 $ find /var/adm -mtime +3 -print 2.1.7 - n e w e r newest_file_name! oldest_file_name f i n d a g e. a w k b e l t s. a w k f i n d t o u c h 23 : 40 2 1 : 4 0 f i n d - n e w e r $ find. -newer dstamp -print 2.1.8 type U N I X L I N U X

18 shell / e t c $ find /etc -type d -print $ find.! -type d -print / e t c $ find /etc -type l -print 2.1.9 size b l o c k N c 1 M $ find. -size +1000000c -print / h o m e / a p a c h e 100 $ find /home/apache -size 100c -print 10 512 $ find. -size +10 -print 2.1.10 depth f i n d d e p t h f i n d f i n f i n d C O N. F I L E $ find / -name "CON.FILE" -depth -print 2.1.11 mount f i n d m o u n t X C $ find. -name "*.XC" -mount -print 2.1.12 cpio c p i o f i n d c p i o c p i o / e t c / h o m e / a p p s

2 f i n d x a rg s 19 \ s h e l l \ / / e t c / e t c f i n d / e t c / h o m e / a p p s c p i o c p i o C 65536 B 5 1 2 C 6 5 5 3 6 6 4 K 6 5 5 3 6 / 1 0 2 4 2.1.13 exec ok shell - e x e c f i n d - e x e c - e x e c l s ls -l r m l s e x e c {} \ e x e c p r i n t f i n d ls -l ls f i n d - e x e c f i n d - e x e c ls -l / l o g s 5 $ find logs -type f -mtime +5 -exec rm {} \; s h e l l m v r m - e x e c f i n d. L O G 5 y n - e x e c g r e p f i n d

20 shell p a s s w d * p a s s w d p a s s w d. o l d p a s s w d. b a k g r e p r o u n d e r 2.1.14 find f i n d f i n d $ H O M E $ find $HOME -print $ find ~ -print s u i d $ find. -type f -perm 4755 -print 0 $ find / -type f -size 0 -exec ls -l {} \; / v a r / l o g s 7 $ find /var/logs -type f -mtime +7 -exec rm {} \; a u d i t $find /-name -group audit -print A d m i n. l o g a d m i n. l o g. 001 a d m i n. l o g. 002 f i n d / l o g s 7 a d m i n. l o g 9 9 9 $ find /logs -name 'admin.log[0-9][0-9][0-9] '-atime +7 -exec rm {} \; $ find. -type d -print -local -mount sort r m t $ find /dev/rmt -print 2.2 xargs f i n d - e x e c f i n d e x e c e x e f i n d x a rg s f i n d F i n d x a rg s x a rg s - e x e c - e x e c

2 f i n d x a rg s 21 x a rg s x a rg s x a rg s f i n d x a rg s (core dump) /tmp/core.log $ find. -name "core" -print xargs echo "" >/tmp/core.log / a p p s / a u d i t $ find /apps/audit -perm -7 -print xargs chmod o-w g r e p d e v i c e $ find / -type f -print xargs grep "device" g r e p D B O $ find. -name -type \ f -print xargs grep "DBO" \ f i n d * s h e l l 2.3 f i n d e x e c x a rg s

3 c r o n t a b a t n o h u p cron At at & Nohup 3.1 cron crontab c r o n c r o n t a b c r o n t a s h e l l c r o n t a b c r o n. d e n y c r o n. a l l o w c r o n t a b 3.1.1 crontab c r o n t a b 1 2 1 5 9 3 1 3 1 4 1 1 2 5 6 1 2 3 0 0 6 0

3 23 c r o n t a b < > < > < > < > < > < > C r o n t a b - 1-5 1, 4 * * 5 # 3.1.2 crontab c r o n t a b 30 21* * * /apps/bin/cleanup.sh 21 : 30 / a p p s / b i n c l e a n u p. s h 45 4 1,10,22 * * /apps/bin/backup.sh 1 1 0 2 2 4 : 45 / a p p s / b i n b a c k u p. s h 10 1 * * 6,0 /bin/find -name "core" -exec rm {} \; 1 : 10 f i n d 0,30 18-23 * * * /apps/bin/dbcheck.sh 18 : 00 2 3 : 00 30 / a p p s / b i n d b c h e c k. s h 0 23 * * 6 /apps/bin/qtrend.sh 11 : 00 p m / a p p s / b i n q t r e n d. s h c r o n t a b s h e l l c r o n c r o n c r o s h e l l c r o n 3.1.3 crontab c r o n t a b Crontab [-u user] -e -l -r -u -e c r o n t a b -l c r o n t a b -r c r o n t a b - u c r o n t a b

24 shell 3.1.4 crontab c r o n c r o n t a b E D I TO R c r o n c r o n t a b 99 % U N I X L I N U X v i $ H O M E. p r o f i l e EDITOR=vi; export EDITOR < u s e r > c r o n < u s e r > d a v e c r o n 5 15 t t y 1 c r o n t a b c r o n $ crontab davecron c r o n 15 / v a r / s p o o l / c r o n d a v e 3.1.5 crontab c r o n t a b $ H O M E c r o n t a b $ crontab -l > $HOME/mycron c r o n t a b 3.1.6 crontab c r o n t a b E D I TO R v i v i c r o n t a b $ crontab -e v i c r o n t a b

3 25 c r o n c r o n t a b c r o n t a b crontab -l 3.1.7 crontab c r o n t a b $ crontab -r 3.1.8 crontab c r o n t a b $ H O M E / v a r / s p o o l / c r o n / < u s e r n a m e > < u s e r n a m e > $ crontab <filename> < f i l e n a m e > $ H O M E $ H O M E c r o n t a b r e c r o n t a b c r o n t a b c r o n t a b c r o n t a b d e l e t e < C t r l - D > c r o n t a b 3.2 at a t c r o n 10 m i n c r o n t a b a t c r o n t a b c r o n t a b / e t c a t. a l l o w a t. d e n y

26 shell a t a c r o n t a b a t at [-f script] [-m -l -r] [time] [date] -f script -l a t q -r I D U N I X a t r m -m time at H H H. H H M M H H : M M H : M H M a. m. p. m. date a t t o d a y t o m o r r o w 3.2.1 at a t a a t s h e l l a t / a t < C T R L - D > < E O T > < C T R L - D > 21 : 10 f i n d job 1 / a t

3 27 a t s h e l l - f d b _ t a b l e. s h 3 : 00 e c h o a t $ echo find /etc -name "passwd" -print at now +1 minute 3.2.2 at -l / a a t a t q a t / v a r / s p o o l / a t 3.2.3 atrm [job no] at -r [job no] at -l at -r at-r [job no] 3.3 &

28 shell & & f i n d s h e l l command >out.file 2>&1 & out.file 3.3.1 f i n d s r m. c o n f f i n d. d t 27015 p s 1 3.3.2 ps p s 1 p s g r e p ps x p s 3.3.3 k i l l s h e l

3 29 k i l l kill -signal [process_number] ( ) k i l l n o h u p 3.4 nohup n o h u p N o h u ( n o hang up) nohup command & 3.4.1 nohup n o h u p n o h u p. o u t nohup command > myout.file 2>&1 m y o u t. f i l e p s 1 s h e l l ps x ps -ef grep ps1 3.4.2 s h e l l n o h u p

30 shell $ chmod 744 quarterend q t r. o u t 3.5 C r o n

4 S h e l l * [...] [ ] [!...] [ ] s h e l l 4.1 * * a p p * a p p * *. d o c. d o c * c l *. s e d c l. s e d c d

32 shell 4.2 R c o n f. l o g f??* s f s 4.3 [...] [!...] [...] [ ] - i o l o g. l o g.[ 0-9 ]* [ 0-9 ] * [! 0-9 ]*! LPS 1

4 33 L P S $ ls [A-Z]* $ ls [a-z]* $ ls [0-9]*.. p r o f i l e. r h o s t s. h i s t o r y $ ls.* 4.4

5 shell s h e l l s h e l l 5.1 echo e c h o echo string e c h o \c \f \t \n $ echo "The red pen ran out of ink" e c h o $ H O M E t t y ( ) LINUX... - n echo

5 s h e l l 35 $ echo -n "What is your name :" -e ( ) e c h o \ n e c h o \ LINUX... - e > m y f i l e $ echo "The log files have all been done"> myfile $ echo "$LOGNAME carried them out at `date`">>myfile m y f i l e s h e l l e c h o \ s h e l l e c h o / d e v / r m t 0 \ $ echo "\"/dev/rmt0"\" " / d e v / r m t 0 " 5.2 read r e a d

36 shell r e a d read varible1 varible2... s h e l l Shell John Lemon Doe s h e l l r e a d LINUX... -n

5 s h e l l 37 5.3 cat c a t c a t m o r e c a t $ cat myfile more $ cat myfile pg c a t cat [options] filename1... filename2... c a t -v m y f i l e $ cat myfile m y f i l e 1 m y f i l e 2 m y f i l e 3 $ cat myfile1 myfile2 myfile3 b i g f i l e $ cat myfile1 myfile2 myfile3 > bigfile c a t c a t < C T R L - D > c a t D O S f t p < C T R L - M > c a t

38 shell < C T R L - D > 5.4 1 2 s h e l l g r e p q u a r t e r 1. d o c 5-1 Is 5-1 s e d a w k g r e p w h o a w k d f a w k a w k a w g r e p f i l e s y s t e m / d e v / s e d

5 s h e l l 39 $ sort myfile lp 5.5 tee t e e T tee -a files - a t e e w h o w h o. o u t 5-2 screen who.out who 5-2 tee t a p e. l o g t e e - a $ who \ s h e l l e c h o

40 shell $ echo "stand-by disk cleanup starting in 1 minute" tee /dev/console - a 5.6 s h e l l s h e l l 0 1 2 12 0 1 2 3 9 5.6.1 0 5.6.2 1 5.6.3 2 5.7

5 s h e l l 41 5-1 5-1 5-1 command > filename command >> filename command 1 > fielname command > filename 2>&1 command 2 > filename command 2 >> filename command >> filename 2>&1 command < filename >filename2 command < filename command << delimiter command <&m command >&m command <&- ( ) ( ) ( ) c o m m a n d f i l e n a m e f i l e n a m e 2 c o m m a n d f i l e n a m e d e l i m i t e r m m 5.7.1 / e t c / p a s s w d I D s o r t. o u t s o r ( ) s o r t $ cat passwd awk -F: '{print $1}' sort 1>sort.out 5-1 $ cat passwd awk -F: '{print $1}' sort >sort.out a c c o u n t f i l e. o u > f i l e n a m e l s l s. o u t $ ls >ls.out ( ) > > f i l e n a m e 0 ' > f i l e n a m e ' $ >myfile

42 shell 5.7.2 a w k $ sort < name.txt s o r t $ sort name.txt s o r t n a m e. o u ( ) $ sort <name.txt >name.out l o u i s e c o n t e n t s. t x t $ mail louise < contents.txt command << delimiter s h e l l d e l i m i t e r s h e l l d e l i m i t e r E O F M AY D AY < < m y f i l e T E R M L O G N A M E 5.7.3 2 g r e p m i s s i l e s t r i d e n t g r e p / d e v / n u l l ( ) $ grep "trident" missiles 2>/dev/null / d e v / n u l l g r e p. e r r

5 s h e l l 43 g r e p > > ( ) 5.8 ( ) a c c o u n t s. o u t $ cat account_qtr.doc account_end.doc 1>accounts.out 2>accounts.err a c c o u n t s. e r r a c c o u n t _ e n d. d o c 5.9 s h e l l $ cleanup >cleanup.out 2>&1 c l e a n u p c l e a n u p. o u t $ grep "standard"* > grep.out 2>&1 g r e p g r e p. o u t 2 > & 1 c a t

44 shell ( i s q l s y b a s e ) f t p 5.10 exec e x e c s h e l l s h e l l s h e l l exec command c o m m a n d s h e l l e x e c s h e l l e x e c. p r o f i l e s h e l l e x e c e x e c s h e l l 5.11 e x e c 4 4 9 s t o c k. t x t 4 s t o c k. t x t 4 l i n e 1 l i n e 2 s t o c k. t x t c p

5 s h e l l 45 5.12 s h e l l ( 3 9 )

6 && s h e l l S h e l l s h e l s h e l l {} 6.1 && && 1 && 2 && 1 ( 0 && 2 && && && & e c h o $ mv /apps/bin /apps/dev/bin && rm -r /apps/bin / a p p s / b i n / a p p s / d e v / b i n / a p p s / b i n q u a r t e r _ e n d. t x t q u a r t e r. s o r t e d q u a r t e r. s o r t e d $ sort quarter_end.txt > quarter.sorted && lp quarter.sorted 6.2 1 2

6 47 1 2 1 5 m o n t h _ e n d. t x t c o m e t s h e l l s h e l $ comet month_end.txt exit 6.3 { } s h e l l s h e l s h e l l s h e l l 1 2... {} s h e l l s h e l l {} s h e l l s h e l l { 1 2...} && c o m e t $ comet month_end.txt exit s h e l l e x i t && $ sort quarter_end.txt > quarter.sorted && lp quarter.sorted s o r t

48 shell 6.4 s h e l l && &&

7 U N I X L I N U X s h e l l s h e l l R E A A x g r e p s e d {\\} a w k 7-1 $ * * 0 [ ] [] - [] [ 1-5 [ 12345 ] \ s h e l l \. p a t t e r n \ { n \ } p a t t e r n \ { n \ } m p a t t e r n \ { n m \ } p a t t e r n n p a t t e r n n m

50 7.1. b e g b e g. n. ls -l... x.. x.. x 10 4 X C...X C.... 4 5 6 X C 4 A S C I I 7.2 ^ ^ ls -l ls -l d 1 ^ 001 ^... 4 X C....

7 51 3 4 X C 4 ^ 4 1 ^... 1 4 c o m p ^ c o m p 4 c o m p i n g ^ c o m p.. i n g 7.3 $ $ ^ $ t r o u b l e t r o u b l e $ 1 d $ 1 d ^ $ ^. $ j e t 01 j e t 0 1 $ 7.4 * c o m p u * t u 1 0 1 3 3 *

52 7.5 \. \. ^ \ ^ *. p a s \ * \. p a s * 7.6 [] [] - [] [ 0 1 2 3 4 5 6 7 8 9 ] - [ 0-9 ] [ a - z ] [ A - Z a - z ] A - Z a - z [ A - Z a - z 0-9 ] [] s t s[a-z A-Z]t

7 53 s [ a - z ] t C o m p u t e r c o m p u t e r [ C c ] o m p u t e r S c o u t s h o u t b o u g h t [ou].*t o u t s y s t e m S [ S s ] y s t e m \. [] * [ [ A - Z a - Z ]* [ A - Z a - z ] * ^ [^a-za-z] [ ^ 0-9 ] ^ 7.7 \{\} * \{\} pattern\{n\} n pattern\{n,\} n pattern\{n,m} n m n, m 0-255 A B A \ { 2 \ } B A A B A 4 A \ { 4, \ } B A A A A B A A A A A A A B A A A A 2 4 A \ { 2, 4 \ } B A A B A A A B A A A A B A B A A A A A B 4 x x 4

54 [ 0-9 ] \ { 4 \ }X X[ 0-9 ] \ { 4 \ } 1) 4 2) x x 3) 4 7-2 7-2

7 55 7.8 s h e l l g r e p, s e d a w k

8 grep g r e p U N I X L I N U X g r e p g r e p g r e g r e p G r e p g r e p E g r e p g r e p \ q F g r e p g r e p f a s t g r e p grep g r e p g r e p g r e g r e p GNU grep g r e p g r e p f g r e p e g r e p g r e p < Ta b > g r e p d a t a.. f d a t a. f 1 2 3 4 5 6 7

8 g rep 57 8.1 grep g r e p grep [ ] [ ] 8.1.1 g r e p m y s t r i n g s h e l l jet plane p l a n g r e p $ M Y VA R 8.1.2 grep g r e p -c -i -h -l -n -s -v 8.1.3. d o c s o r t $ grep "sort"*.doc sort it $ grep "sort it" * g r e p 8.1.4 $ grep -c "48"data.f $ 4 g r e p 4 4 48 48 4

58 8.1.5 48 8.1.6 48 8.1.7 48 484 4 83 4 8 4 < Ta b > < Ta b > t a b g r e p \ > 48 8.1.8 g r e p - i d a t a. f S e p t 8.2 grep g r e p s h e l l

8 g rep 59 8.2.1 484 4 83 [] 48 3 4 484 4 8 8.2.2 48 ^ 8.2.3 - i S e p t [] S e p t s e p t S e p t 483 g r e p g r e 8.2.4 L D 5 C 8.2.5 5 1996 1 998 5.. 199 [ 6, 8 ] 5 199 6 8

60 1998 [ 0-9 ]\{ 3 \}[ 8 ] 3 8 8.2.6 [] 0 5 0 6 ^ 8.2.7 4 4 999 9 9 2 6 8 2 6 3

8 g rep 61 8.2.8 grep g r e p - E 219 2 1 6 8.2.9 ^ $ - n 8.2.10 $. ' " * [] ^ \ +?, \. c o n f t r o l l. c o n f 8.2.11 f i l e n a m e. d e p o s i t 8.2.12 IP D N S I P I P 2000 n n n. n n n n n n. n n.. nnn.nnn IP [ 0-9 ]\{ 3 \}\.[ 0-0 \{ 3 \}\ 3

62 8.3 g r e p 8-1 [ [ : u p p e r : ] ] [ A - Z ] [ [ : a l n u m : ] ] [ 0-9 a - za-z] [[: l o w e r :]] [ a - z ] [[: s p a c e :]] t a b [ [ : d i g i t : ] ] [ 0-9 ] [ [ : a l p h a : ] ] [ a - z A - Z ] 5 P D * g r e p * g r e p d e v i c e 8.4 grep g r e p

8 g rep 63 8.4.1 8.4.2 passwd / e t c / p a s s w d l o u i s e g r e p 'No such file or directory' g r e p - s g r e p - s 2 > $ 1 / d e v / n u l l g r e p e x i t g r e p / t m p p a s s w d. o u t 8.4.3 ps ps x g r e p ps x D N S n a m e d g r e p g r e p ps x g r e p - v p s g r e p

64 ps x ps -ef 8.4.4 grep g r e p e c h o g r e 8.5 egrep e g r e p e x p r e s s i o n extended grep e g r e p e g r e p e g r e p - f g r e p s t r i n g s 484 4 7 d a t a. f 484 4 7 - f 32 L 2 C C l o u i s e m a t t y pauline w h o e g r e p ^ m a t t y p a u l i n e s h u t d o w n s h u t d o w n s r e b o o t r e b o o t s e g r e p

8 g rep 65 8.6 g r e p U N I X D O S g r e p g r e p s h e l l U N I X

9 AWK a w k a w k s h e l l a w k Bailing out a w k : c m d. L i n e : a w k s h e l l a w k a w k a w g r e p s e d s h e l l a w k a w k a w k a w k a w k a w k a w k s e d g r e p a w k a w k A h o. We n i n b e rg e r K e r n i g h a m n a w k g a w k a w k a w a w k 9.1 awk a w k c o m m a n d s a w k [- F ] a w k p a s s w d - F a w k a w k a w a w k

9 AWK 67 - f a w k _ s c r i p t _ f i l e a w k i n p u t _ f i l e ( s ) a w k 9.2 awk a w k a w k - F a w k - F a w k a w k 9-1 a w k # n a w k 9-1 awk 1 2 3 4 P. B u n n y ( 1 ) # 02 / 99 # 48 # Yellow \n J. Tr o l l ( 2 ) # 07 / 99 # 4842 # Brown-3 \n 9.2.1 a w k a w k B E G I N E N D B E G I N B E G I N E N D a w k a w k {} i f l o o p i n g a w k 9.2.2 a w k $ 1 $ 2... $ n $ 1, $ 3 1 3 5 $ 1, $ 2, $ 3, $ 4, $ 5 $ 0 Aw k $ s h e l l $ p r i n t a w k

68 1. g r a d e. t x t 7 1 2 3 4 5 6 7 - F 2. a w k s h e l l a w k > w o w t e e d e l e t e _ m e _ a n d _ d i e a w k tee delete_me_and_die 3. a w k a w k 4. a w k {print $0}( )

9 AWK 69 5. f i e l d - 1 f i e l d - 4 $ 1 $ 4 6. t a b t a b t a b \ t n a m e b e l t \ n \ n B E G I N a w k 7. end of report E N D E N D E N D 8. awk a w k a w a w k

70 a w k a w k a w k a w k 9. awk g r a d e. t x t B E G I N a w k s h e l l a w k a w <Ct r l - D > a w k 9.2.3 awk g r e p a w k G r e e n / G r e e n / G r e e n 9.2.4 a w k 7 \ ^ $. [] () * +? 7 a w k g r e p s e d + + /X Y?Z/ X Y Z Y Z 9.2.5 9-2 a w k

9 AWK 71 9-2 awk 1. < > = < = ~ = =! ~!= i f a w k i f g r a d e. t x t b r o w n f i e l d - 4 {if($4~/brown/) print } f i e l d - 4 b r o w n {} a w k i f b r o w n 2. 48 4 f i e l d - 3 48 a w k 48 48 = = $ 3 = = 4 8 48 3. ~! ~ b r o w n $0!~/brown/ b r o w n a w k

72 f i e l d - 4 awk$4!="brown"{print $0} grade.txt b r o w n b r o w n b r o w n - 2 b r o w n - 3 b r o w n - 2 4. f i e l d - 6 f i e l d - 7 5. 6. 7. [] [ g r e e n /[ G g ] r e e n / 8. a. / ^... a / a 9. y e l l o w b r o w n

9 AWK 73 Ye l l o w B r o w n G r e e n g r e e n [] 10. 48 ^ a w k 7 7 a w k && AND : O R! 11. AND P. B u n n y Ye l l o w ( $ 1 = = " P. B u n n y "&& $ 4 = = " Ye l l o w ") && 12. Or Ye l l o w B r o w n 9.2.6 awk a w k 9-3 9-3 awk A R G C A R G V E N V I R O N FILENAME F N R F S a w k - F

74 N F N R O F S O R S R S A R G C a w k A R G V A R G C A R G V [ n ] n E N V I R O N E N V I R O N [ E D I TO R ] = Vi F I L E N A M E a w k a w k F N R a w k N R F S a w k - F F S = " " N F O F S # O F S = "#" O R S \ n R S (\ n ) 9.2.7 NF NR FILENAME a w k N R N R print NR E N D N F E N D B r o w n A N D B r o w n

9 AWK 75 / N F $ P W D a w k 9.2.8 awk a w k = += *= / = %= ^ = &&! ~! ~ < <= ==!= >> + - * / % ^ + + -- 1. a w k n a m e = $ n n a m e n n a m e b e l t n a m e = $ 1 ; b e l t s = $ 4 a w k n a m e b e l t s Ye l l o w 2. 1) B E G I N 2) B E G I N a w k 27 2 7 2 7

76 B A S E L I N E B E G I N 3. a w k a w k a w k N R N F $ 1 = $ 1 + 5 1 5 M. Ta n s l e y 40 39 $ 6 = $ 6-1 4. J. Tr o l l J. L. Tr o l l $ 1 = " J. L. Tr o l l " " 5. 100 6. a w k { $ 4 = $ 2 + $ 3 } 3 4 2 3 g r a d e. t x t 8 { $ 8 = $ 7 - $ 6 } B E G I N t a b

9 AWK 77 7. + = $ 1 t o t a l t o t a l + = $ 1 a w k t o t + = $ 6 t o t a w k 6 E N D 6 a w k 8. ls -l a w k a w k d E N D ls -l d 5 9 d ^ [ ^ d ] t o t

78 9.2.9 a w k 9-4 9-4 awk g s u b ( r, s ) g s u b ( r, s, t ) i n d e x ( s, t ) l e n g t h ( s ) m a t c h ( s, r ) s p l i t ( s, a, f s ) s p r i n t ( f m t, e x p ) s u b ( r, s ) s u b s t r ( s, p ) s u b s t r ( s, p, n ) $ 0 s r t s r s t s s r f s s a f m t e x p $ 0 s s p s p n g s u b s e d $ 0 g s u b $ 0 i n d e x s t s t l e n g t h s m a t c h s r s p l i t f s s a s p r i n t p r i n t f f m t e x p s u b r s $ 0 r s u b s p s p s u b s t r s p n a w k 1. gsub / / / 4842 4 899 2. index s t B u n n y n y 3. length J. Tr o l l

9 AWK 79 4. match m a t c h 0 A N C D d 0 A N C D D A N C D D J. L u l u 5. split s p l i t - A D2 - K P 9 - J U 2 - L P - 1 s p l i t (" A D 2 - K P 9 - J U 2 - L P - 1 " p a r t s _ a r r a y " -" s p l i t 4 s p l i t m y a r r a y m y a r r a y 6. sub s u b S T R poped popo pill s u b s u b / o p / " o p " S T R o p po Ped pope pill J. Tr o l l 29 24 s u b / 26 / " 29 " $ 0 24 J. Tr o l l 7. substr s u b s t r 1 5

80 a w k L Ta n s l - e y 3 7 99 a w k s u b s t r 1 B E G I N E N D t 8. s h e l l a w k a w k a w k a w k s t a n d - b y a w k a w k a w k 9.2.10 \ n \ n {} /\{/ a w k 9-5 a w k 9-5 awk \ b \ t t a b \ f \ d d d \ n \ c \\ \ r

9 AWK 81 May Day t a b May Day 104 1 41 1 71 D a y \ 104 D A S C I I \ 141 a A S C I I 9.2.11 awk printf t a b a w k p r i n t f p r i n t f % p r i n t f p r i n t f [ ] 9.2.12 printf 9-6 awk printf - Wi d t h 0 0. p r e c 1. 9-7 awk printf % c A S C I I % d % e % f 123. 44 % g a w k e f % o % s % x A S C I I 65 65 a w k p r i n t f A S C I I p r i n t f a w k 999 2.

82 15 \ n p r i n t p r i n t f 3. a w k a w k a w k a w k a w k awk = a w k A G E 10 a w k 10 a w k df -k a w k 4 $ 4 ~ / ^ [ 0-9 ]/ 1 024 d f i f ( $ 4 < T R I G G E R ) T R I G G E R df -k d f a w k w h o w h o a w k L O G N A M E w h o a w k

9 AWK 83 r o o t root you are connected to ttyp1 4. awk a w k a w k a w k awk t o t + = $ 6 END{print "club student total points " t o t } g r a d e. t x t s t u d e n t _ t o t. a w k a w k a w k a w k /bin/awk -f a w k

84 E R R O R * a w k a w k a w k a w k 5. a w k F S F S # F S

9 AWK 85 a w k F S B E G I N a w k F S / e t c / p a s s w d 1 5 p a s s w d 1 5 6. a w k a w k a w k awk script_file var=value input_file N F M A X / e t c / p a s s w d p a s s w d 7 a w k

86 a w k d u d u a w k 9.2.13 awk s p l i t s p l i t m y a r r a y m y a r r a y For (element in array ) print array[element] 123 # 456 # 678 s p l i t / d e v / n u l l

9 AWK 87 s p l i t # 1) Ye l l o w O r a n g e R e d 2 ) 20 6 a w k a w k

88 B E G I N F S # Ye l l o w O r a n g e R e d B E G I N B E G I N c o l o r 1 Ye l l o w O r a n g e R e d S e n i o r _ o r _ j u n i o r 2 j u n i o r s e n i o r E N D \ a w k 9.3 a w k a w k a w k a w k s h e l l s h e l l a w k

10 sed s e d s e d Vi s e d s e s e d s e d s e d s e a w k s e d s e s e d s e d s e d s e g r e p a w k s e d g r e p a w k 10.1 sed s e d 10.2 sed s e d s e s e d s e d s e d s e d sed [ ] s e d s e d s e s e d sed [ ] -f sed s e d s e d

90 s e d [ ] s h e l l s e d s e d n s e d p c s e d f s e d s e s e d sed -f myscript.sed input_file m y s c r i p t. s e d s e d 10.2.1 sed s e d m y o u t f i l e 10.2.2 sed s e d 1) 2 ) 7 1 0-1 s e d 10-1 s e d x x, y x 1 x y 2 5 2 5 / p a t t e r n / / d i s k / /[a-z]/ / p a t t e r n / p a t t e r n / / d i s k / d i s k s / p a t t e r n /, x x, / p a t t e r n / x, y! / r i b b o n /, 3 3./ v d u / x y 1, 2! 10.2.3 sed 1 0-2 S e d p 10-2 sed = a \ i \ d c \

10 sed 91 s r w q l A S C I I { } n g y n 2 /pattern n/ s e d q u o t e. t x t 10.3 sed s e d \ 7 s e d 10.4 sed s e d 10.4.1 p rint p r i n t [ a d d r e s s [ a d d r e s s ] P s e d - n 10.4.2 1 3

92 10.4.3 N e a v e / p a t t e r n / / N e a v e 10.4.4 s e d q u o t e. t x t t h e s e d t h e l i n e _ n u m b e r, / p a t t e r n / 4,/ t h e / t h e 10.4.5 $ \ /\$/ p 10.4.6 1, $ $ 10.4.7 0 i n g /.* i n g / i n g 10.4.8

10 sed 93 10.4.9 $ $ 10.4.10 = / p a t t e r n / - e s e d e = sed -n -e /pattern/p -e /pattern/= 10.4.11 a \ s e d s e d s e d s e d s e d a\ s e d a \ s e d s e d s e d s h e l l s e d

94 10.4.12 sed a p p e n d. s e d file not found.\ s e d s e / b i n / c o m p a n y / a \ s e d 10.4.13 a t t e n d a n c e utter confusion followed

10 sed 95 4 10.4.14 The honeysuckle band played all night long for only $90 The office Di b b l e band played well / H o n e y s u c k l e / s e d c h a n g e. s e d chmod u+x change.sed

96 10.4.15 s e d [ a d d r e s s [ a d d r e s s ] ] d 1 d N e a v e 10.4.16 [ a d d r e s s [ address]] s/ pattern-to-find /replacement-pattern/[g p w n] s s e d p a t t e r n - t o - f i n d r e p l a c e m e n t - p a t t e r n g g p s e d p - n - n w

10 sed 97 n i g h t N I G H T n i g h t N I G H T $ 9 0 $ \ r e p l a c e m e n t - p a t t e r n s e d g T h e Wo w w s p l e n d i d S P L E N D I D s e d. o u t s e d 10.5 & & & s e d s/nurse/"hello"&/p The local nurse Miss P.Neave was in attendance The honeysuckle band played all night long for only $90 10.6 sed > s e d

98 [ a d d r e s s [ address]]w filename w s e d f i l e n a m e q u o t e. t x t 1 2 f i l e d t N e a v e f i l e d h t 10.7 s e d address r filename r s e d f i l e n a m e s e d e x. t x t s e d e x. t x t q u o t e. t x t / c o m p a n y / 10.8 s e d address q /. a.*/ a 0 q s e d

10 sed 99 10.9 cat -v filename cat filename c a t - v s e d [ a d d r e s s [ a d d r e s s ] ] l l l 1 $ c a t s e d s e d \ 033 O P F 1 t e r m i n f o t e r m c a p F 1 v i v i < C t r l > < v > a ^ F 1 [ O P ] < E S C > F 1 10.10 sed s e d s e 10.10.1 s e d d o s. t x t

100 1) ## 2) 0 0 0 3) ^ M ^ @ ^ L d o s. t x t 1 # # 2 0 ^ ^ 0 * 0 s / ^ 0 *// g 3 ^ M s / ^ m // g ^ M ^ M F 1 sed s/ < C t r l > v v ^ < C t r l > < r e t u r n > ^ M s e d c a t s e d s e d s e d

10 sed 101 s e d s e 10.10.2 s q l 1) s /-*// g ------ 2) / ^ $ / d 3) $ d 4) 1 d 5) awk {print $1} c a t s e d 10.10.3 U N H U N D U N H U N D [ 0-9 ]

102 10.10.4 p a s s e d $ 10.10.5 shell sed s e d 10.10.6 sed shell s e d s h e l l s h e l N E W- N A M E s e d 10.11 [ ] [ t a b s /\. $ // g -e /abcd/d s /[][][]*/[]/ g s / ^ [][]*// g s /\.[][]*/[]/ g / ^ $ / d s / ^.// g s /CO L \(...\)// g s / ^ \/// g s /[]/[]// g S / ^ []// g s /[]*// g a b c d C O L \ t a b t a b t a b

10 sed 103 1. \ s e d \ 2. / "Mr Wi l l i s " s e d M r " B r u c e " 3. s e d a c c o u n t s. d o c 4. s e d a c c o u n t s. d o c 5. s e d. d o c a c c o u n t s 6. x s e d 10.12 s e d s e d s e d s e s e d

11 P I C K U N I X P I C K P I C K s o r t uniq join cut paste split 11.1 sort s o r t s o r t U N I X 11.1.1 U N I X / L I N U X s o r t s o r s o r t s o r t s o r t s o r t s o r t s o r t u n i q j o i n c u t p a s t e s p l i t s o r t 11.1.2 sort s o r t sort -cmu -o output_file [other options] +pos1 +pos2 input_files s o r t -c -m -u -o s o r t

11 105 -b -n -t t a b -r +n n n n + post1 m n m n 4 6 5 7 11.1.3 - o r e s u l t s. o u t 11.1.4 sort s o r t - s o r t - t 0 1 s o r t v i d e o. t x t 1 2 3 4 - t 11.1.5 sort s o r t 0 1 s o r s o r t 0 1 11.1.6 30 40 s o r t - c

106 s o r t 11.1.7 sort s o r t sort filename 0 s o r t s o r t 11.1.8 sort s o r t - r s o r t 0 11.1.9 2 1 t 1 2 3 11.1.10 t 3

11 107 - n - n 3 2 t 3 The Hill s o r t 3 - n A l i e n s - r A l i e n s 11.1.11 - u A l i e n A l i e - u s o r t

108 11.1.12 k sort s o r t k 1 1 1 s o r t k 1 - k 4 11.1.13 k 4 1 -k4 -k1 11.1.14 sort - n s o r t 0 2 3 11.1.15 pos f i e l d _ n u m b e r c h a r a c t e r s _ i n

11 109 + 1. 2 1 3 11.1.16 head tail s o r t 4 - k 4 s o r t h e a d head -1 t a i l h e a d 1 2 tail -1 s o r t t a i l h e a d t a i l h e a d Ta i l h e a d t a i l 10 20 7 11.1.17 awk sort s o r t a w k s o r t a w k

110 11.1.18 sort -m sorted_file1 sorted_file2 -m +o v i d e o. s o r t + o 11.2 sort s o r t / e t c / p a s s w d 1 a w k a w k s o r t d f d - b 4 + 4 I P I P I P

11 111 I P 3 11.3 uniq u n i q u n i u n i q s o r t s o r t u n i q u n i q u n i q May Day 4 May Day u n i q -u -d -c -f n n - f - n m y f i l e. t x t u n i q 5 May Day sort -u May Day Going Down

112 - c May Day 1. - d 2. - n - 5 5 1 1 2 - n 2 u n i q 1 u n i q O P - f 11.4 join j o i n S Q L j o i n j o i n f i l e 1 f i l e 2 j o i n t a b j o i n 20 2 D B M S j o i n

11 113 an n n - a 1 - a 2 o n.m n m 1. 3 1 n m 1. 3 2. 1 j n m n m t t a b - t n a m e. t x t t o w n. t x t M. G o l l s 12 Hidd Rd 0 j o i n j o i n 1. j o i n - a P. H e l l e r 2. - o j o i n 1. 1 2. 2

114 -jn m 1 3 2 p e r s I D p e r s 2 I D p e r s 4 p e r s 2 2 j o i n 4 j o i 5 a w k $ awk '{print $4}' 11.5 cut c u t c u t cut [options] file1 file2 -c list -f field -d t a b - c - c 1 5-7 1 5 7 -c1-50 50 -f - c -f 1 5 1 5 - f 1 10-12 1 10 12 p e r s ' p e r s '

11 115 11.5.1 - d - d 3 - f 3 I D 11.5.2 c u t 1 3 I D / e t c / p a s s w d 1 3 - c c u t ls -l - c ls -l cut -c1-10

116 11.6 paste c u t p a s t e p a s t e p a s t t a b - d p a s t e paste -d -s -file1 file2 -d t a b @ - d -s - ls -l paste p a s t e 11.6.1 11.6.2 t a b - d - s I D

11 117 11.6.3 paste p a s t e - - 4 11.7 split s p l i t v i s o r t s p l i t split -output_file-size input-filename output-filename o u t p u t - f i l e - s i z e s p l i t o u t p u t - f i l e - s i z e 1000 2800 3 1000 1 000 8 00 x [ a a ] x [ z z ] x [ a a ] [ z z ] b i g o n e. t x t 2 800 s p l i t o u t p u t - f i l e - s i z e 6

118 2 6 s p l i t 11.8 s o r t j o i n s p l i t u n i q c u t p a s t e

12 tr 12.1 tr t r t t r 1 2 t r 1 2 t r tr-c-d-s["string1_to_translate_from"]["string2_to_translate_to"] input_ f i l e -c 1 A S C I I -d 1 -s I n p u t - f i l e 12.1.1 t r 1 2 [a-z] a-z [A-Z] A-Z [0-9] /octal A S C I I [O*n] O n [ O * 2 ] O O t r [ c l a s s ] c n t r l 12-1 [] [ \ 012 ] \ 012 t r t r

120 \{ 12-1 tr \ a Ctrl-G \ 007 \ b Ctrl-H \ 010 \f Ctrl-L \ 014 \n Ctrl-J \ 012 \ r Ctrl-M \ 015 \t Ctrl-I tab \ 011 \ v Ctrl-X \ 030 12.1.2 r e s u l t s. t x t c o p s. t x t 12.1.3 v i - s [ a - z ] t r c a t t r 12.1.4 p l a n e. t x t

12 tr 121 - s \ 012 \ n 12.1.5 t r [ a - z ] [ A - Z ] t r [ l o w e r ] [ u p p e r ] f i l e - t o - t r a n s l a t e n e w - f i l e - n a m e 12.1.6 f i l e - t o - t r a n s l a t e n e w - f i l e - n a m e 12.1.7 - c - s [ a - z ] [ A - Z ] tr -cs "[a-z][a-z]""[\012*]"

122 [ a - z ] [ A - Z ] 1 - s - c t r 12.1.8 t r d o s U N I X f t p c a t - v ^ ^ ^ ^ ^ ^ t a b C t r l - M C t r l - Z - s A S C I I ^ 136 ^ M 0 15 t a b 011 ^ Z 0 32, t a b ^ ^ ^ ^ ^ ^ "\ 136 ""[\ 011 *]" s t a t. t m p ^ M \ n ^ Z s t a t. t m p 12.1.9 ^ M

12 tr 123 D o s U N I X ^ M ^ Z t a b p a s s w d t a b t a b 011 p a s s w d t r t a b 12.1.10 [ c h a r a c t e r * n ] 0 0 0 [ 0 * 4 ] 4 0 12.2 t r s e d t r t r

13 / e t c / p a s s w d / e t c / p a s s w d $HOME.profile $ H O M E. p r o f i l e / e t c / p a s s w d 7 1 2 5 6 7 s h e l l / b i n / s h Bourne Shell P a s s w d p a s s w / e t c / p r o f i l e. p r o f i l e p r o f i l e 13.1 /etc/profile / e t c p r o f i l e PAT H

PAT H / e t c / p r o f i l e

p r o f i l e Q U I T < C t r l - c > L O G N A M E m a n M A N PAT H m a n v t 220 u m a s k < C t r l -C> Q U I T s t t y

/ v a r / a d m / m e s s a g e s u l i m i t i d n k p s a l o m d a v e p r o f i l e 13.2 $HOME.profile / e t c / p r o f i l e $ H O M E p a s s w d $ H O M E 2. p r o f i l e s h e l l / e t c / p r o f i l e. p r o f i l e s h e l l. p r o f i l e p r o f i l e. p r o f i l e u s e t / e t c / p r o f i l. p r o f i l e. p r o f i l E D I TO R c r o n T E R M v t 100 v t 22 b i n p a t h b i n PAT H p w d A S C I I 251 169

L I N U X e c h o / u s r / a d m i n A D M I N = / u s r / a d m w h o w c. p r o f i l e. p r o f i l e / e t c / p r o f i l e. / p a t h n a m e / f i l e n a m e. p r o f i l e $..profile $../profile. p r o f i l e 13.3 stty s t t y s t t stty -a

s t t y ^? < C t r l - H > s t t y stty name character ^ H $ stty erase '\^H'. p r o f i l e s t t y ' C o n t r o l H ' v i C t r l V V H s t t y i n t r ^ C e c h o e c h o - e c h o e c h o e o f ^ D k i l l ^ Y s t a r t ^ Q s t o p ^ S s t t y stty -g s t t y s t t / e t c / p r o f i l e stty -g s t t y s t t y s t t y stty -g e c h o s t t y LINUX L I N U X e c h o - e echo -e

s t t y s t t 13.4.logout Bourne shell s h e l l. l o g o u t e x i t r a p t r a p Bourne shell. l o g o u t. p r o f i l e trap "$HOME /.logout"0. l o g o u t. l o g o u t s h e l l 0 s h e l l s h e l l. p r o f i l e t r a p. l o g o u t 13.5. p r o f i l e

14 shell s h e l l s h e l s h e l l s h e l l 4 s h e l l shell 14.1 shell E D I TO R E D I TO R c r o n E D I TO R E D I TO R v i $ isql -Udavet -Pabcd -Smethsys - S D S Q U E RY D S Q U E RY - S D S Q U E RY $ isql -Udavet -Pabcd 14.2 s h e l l f i l e - n a m e l o o p. d o c s h e l l s h e l l s h e l l 1 4-1 s h e l l

14 $ variable-name=value $ { v a r i a b l e - n a m e = v a l u e } s h e l l 14-1 Va r i a b l e - n a m e = v a l u e Va r i a b l e - n a m e + v a l u e Va r i a b l e - n a m e :? v a l u e Va r i a b l e - n a m e? v a l u e Va r i a b l e - n a m e : = v a l u e Va r i a b l e - n a m e :- v a l u e v a r i a b l e - n a m e v a r i a b l e - n a m e v a r i a b l e - n a m e v a r i a b l e - n a m e v a r i a b l e - n a m e v a r i a b l e - n a m e 14.2.1 e c h o $ L O G N A M E e r r o r- m s g s h e l l $ L O G N A M E 14.2.2 u n s e t unset variable-name 14.2.3 shell s e t s h e l l

s e t s h e l l 14.2.4 14.2.5 $ { v a r i a b l e :- v a l u e } c o l o u r b l u e e c h o c o l o u r $ { v a r i a b l e : = v a l u e } 03 : 00 We e k l y a t

14 f i l e $ { v a r i a b l e : + v a l u e } v a r i a b l e = " " $ D E T I N A T I O N = " " 14.2.6 s o u r c e p a s s w d d e s t c p d e v i c e m t 14.2.7 v a r i a b l e - n a m e = v a l u e readonly variable-name

r e a d o n l y 14.3 s h e l l s h e l l. p r o f i l e / e t c / p r o f i l e p r o f i l e x p o r t 14.3.1 V A R I A B L E - N A M E = v a l u e export VARIABLE-NAME V A R I A B L E - N A M E = v a l u e Export VARIABLE-NAME 14.3.2 e n v

14 14.3.3 u n s e t 14.3.4 shell Brourne shell / e t c / p r o f i l e s h e l l 1. CDPAT H c d C D PAT H c d C D PAT H C D PAT H $ CDPATH=:/home/dave/bin:/usr/local/apps export CDPATH. $ cd apps c d C D PAT H a p p s 2. EXINIT E X I N I T v i v 10 t a b $ EXINIT='set nu tab=10';export EXINIT 3. HOME H O M E p a s s w d 2 H O M E c d $ cd $ HOME 4. IFS

I F S s h e l l t a b I F S I F echo PAT H $ IFS=<space><tab>; export IFS < s p a c e > < t a b > t a b 5. LOGNAME 6. MAIL M A I L /var/spool/mail/<login name> s h e l l M A I L $ MAIL=/usr/mail/dave export MAIL 7. MAILCHECK M A I L C H E C K 60 s 2 m $ MAILCHECK=120 export MAILCHECK 8. MAILPAT H M A I L PAT H M A I L $ MAILPATH=/var/spool/dave:/var/spool/admin export MAILPATH M A I L d a v e a d m i n 9. PAT H PAT H H O M E $ PATH=$HOME/bin:.:/bin:/usr/bin export PATH H O M E / b i n / b i / u s r / b i n PAT H / e t c / p r o f i l e $ PATH=$PATH:/$HOME/bin:. export PATH / e t c / p r o f i l e PAT H $ H O M E / b i n 10. PS1 s h e l l # $

14 11. PS2 P S 2 > P S 2 12. SHELL S H E L L s h e l l / e t c / p a s s w d s h e l l s h e l l 13. TERMINFO / u s r / l i b / t e r m i n f o / u s r / s h a r e / t e r m i n f o $ TERMINFO=/usr/lib/terminfo export TERMINFO 14. TERM T E R M T E R M v t 100 v t 200 v t 220-8 $ TERM=vt100 export TERM 15. TZ G M T 0 E D T 14.3.5 1. EDITO R $ EDITOR=vi export EDITOR 2. PWD c d 3. PA G E R p g m o r e m a n $ PAGER='pg -f -p%d' export PAGER 4. MANPAT H

m a n $ MANPATH=/usr/apps/man:/usr/local/man export MANPATH 5. LPDEST P R I N T E R $ LPDEST=hp3si-systems 14.3.6 set $ H O M E. p r o f i l e s e t - a set -a / e t c / p r o f i l e $ H O M E. p r o f i l e 14.3.7 s h e l l f a t h e r c h i l d f a t h e r f i l m A Few Good Men c h i l d f i l m Die Hard f a t h e r

14 f a t h e r f i l m c h i l d f i l m f a t h e r e x p o r t c h i l d f i l m e x p o r t f i l m f i l m 14.4 4 s h e l l 9 s h i f t s h i f t 9 $ 0 Did You See Th e Full Mo o n $ 0 $ 1 $ 2 $ 3 $ 4 $ 5 $ 6 $ 7 $ 8 $ 9 Did Yo u S e e T h e F u l l M o o n

14.4.1 6 7 8 9 $ 0 b a s e n a m e $ 14.4.2 f i n d $ 1

14 $ 1 g r e p i d g r e p i d p a s s w d 14.4.3 s h e l l 7 1 4-2 14-2 s h e l l $ # $ * 9 $ $ I D $! I D $ @ $ # $ - s h e l l s e t $? 0 p a r a m

I D 14.4.4 $? 0 0 1 / t m p $? $? c p c a n n o t... / d e v / n u l l b i n b i n $! 1

14 14.5 s h e l l s h e l

15 15.1 s h e l l s h e l * s h e l l s h e l l 15-1 15-1 shell " " ' ' \ 15.2 $ ` \ s h e l l

m y d a t e s h e l l " " m y d a t e d a t e d a t e g r e p Davey Wi r e g r e p D a v e y Wi r e s h e l l s h e l l $ b o y $ B O Y 15.3 s h e l l 15.4 s h e l l s h e l l h e l l o h e l l d a t e s h e l l

m y d a t e m y d a t e d a t e m y d a t s h e l l 15.5 s h e l l & * + ^ $ ` "? e c h o * $ echo \* * $ $ s h e l l I D $ $ A S C I I s h e l l

L I N U X - e e x p r * * e c h o $ 19. 99 $ $ 15.6 1) 2)

s h e l l 16 shell s h e l l s h e l l s h e l l shell shell 16.1 shell s h e l l s h e l l U N I X L I N U X s h e l l s h e l l 16.2 #!/ b i n / s h s h e l l Bourne shell #

152 s h e l l 16.3 c l e a n u p / u s r / a d m / / u s r / l o c a l / a p p s / l o g c h m o d $ chmod u+x cleanup $ cleanup $ cleanup sh:cleanup:command not found $. /cleanup s h e l l. p r o f i l e PAT H $ H O M E $ pwd $ /home/dave/bin p w d b i n. p r o f i l e $ H O M E / b i n P A T H = $ P A T H : $ H O M E / b i n b i n $ cd $HOME $ mkdir bin. p r o f i l e b i n PAT H. p r o f i l e $../profile 2 13

16 shell 153 c h m o d 16.4 s h e l l s h e l l

17 Te s t i f t h e n e l s e t e s t e x p r e x p r $? t e s t e x p 0 1 17.1 t e s t test condition [ c o n d i t i o n ] 17-1 17-1 - d - s 0 - f - w - L - u s u i d - r - x s c o r e s. t x t 0 0 s c o r e s. t x t s c o r e s. t x t a p p s b i n

17 155 a p p s b i n s u i d s u i d 17.2 O K s h e l l -a -o s c o r e s. t x t r e s u l t s. t x t r e s u l t s. t x t 17.3 5

156 s h e l l s t r i n g _ o p e r a t o r = = -z -n E D I TO R v i e c h o t a p e t a p e 2 t a p e t a p e 2 17.4 " n u m b e r " n u m e r i c _ o p e r a t o r " n u m b e r " [ " n u m b e r " n u m e r i c _ o p e r a t o r " n u m b e r " ] n u m e r i c _ o p e r a t o r -eq -ne -gt -lt -le -ge 130

17 157 1 1 30 20 130 10 s o u r c e _ c o u n t d e s t _ c o u n t : too many arg u m e n t s 17.5 expr e x p r expr argument operator argument e x p r s h e l l

158 s h e l l 17.5.1 e x p r 0 1 e x p r 17.5.2 e x p r d e v / n u l l 0 e x p r 1 h e l l o h e l l o e x p r 1 0 h e l l o h e l l 17.5.3 e x p r e x p r.* 0 e x p r. d o c

17 159 17.6 e x p r t e s t if then else c a s e

18 while f o r until loops if then else 18.1 $ echo $? 4 $? $ $ s h e l l s h e l l 19 s h e l l e x i t exit n n e x i t s h e l l s h e l e x i t s h e l l 0 1 s h e l l s h e l l s h e l l # 18.2

18 161 s h e l l 18.2.1 i f t h e n e l s e 0 1 c a s e 18.2.2 3 for Until u n t i l While w h i l e f o r f o e c h o L I N U X B S D e c h o echo -e -n e c h o U N I X V B S D e c h o 19 s h e l l 18.3 if then else i f 0 1 i f if 1 then 1 elif 2 then 2 else 3

162 s h e l l f i i f If 1 1 Then 1 1 elif 2 1 then 2 2 else fi 1 2 3 3 i f f i i f f i e l i f e l s e e l i f e l s I f e l i f i if then fi 18.3.1 if i f i f then f i i f t h e n i f if t h e n f i 10 12 i f e c h o e l s e 18.3.2

18 163 r e t u r n n a m e 18.3.3 grep g r e p i f g r e p g r e D a v e d a t a. f i l e D a v e \ > g r e p g r e 0 g r e i f g r e p i f 18.3.4 grep g r e p g r e p P e t e r

164 s h e l l 18.3.5 c p m y f i l e m y f i l e. b a k basename $0` >/dev/null 2>&1 18.3.6 D I R E C TO RY "/" / 1

18 165 18.3.7 i f t e s t. t x t L O G N A M E 18.3.8 i f $ # 3 18.3.9 c r o n a t

166 s h e l l t e s t - t t e s t 1 18.3.10 if else i f if t h e n e l s e f i 1 i f e l s e 18.3.11 E D I TO R E D I TO R 18.3.12 L O G N A M E r o o t L O G N A M E r o o t r o o 1 r o o t L O G N A M E e l s e f i r o o t

18 167 18.3.13 $ 1 D I R E C TO RY ls -A 18.3.14 null t h e n e l s e i f s h e l l t h e n

168 s h e l l 18.3.15 D I R E C TO RY if ["$DIRECTORY"=""] if[$# -lt 1] Y y

18 169 18.3.16 c p $ 1 $ 2 / d e v / n u l l s o r t a c c o u n t s. q t r 3 0 0 18.3.17 if i f i f f i 18.3.18 E D I TO R

170 s h e l l v i v i y Y y $ E D I TO R = r e t u r n -z $EDITO R v i E D I TO R v E D I TO R E D I TO R 18.3.19 *. t x t

18 171 18.3.20 100 y Y C O U N TO R

172 s h e l l 18.3.21 s t t y p a s s w d s t t y I D m a y d a y I N VA L I D _ U S E R I N VA L I D _ PA S S W D n o y e s I D I D d a v e p a u l i n e

18 173 18.3.22 elif if then else e l i f 18.3.23 elif e l i f r o o t l o u i s e d a v e r o o t l o u i s e d a v e

174 s h e l l 18.3.24 / u s r / o p t s / a u d i t / l o g s / u s r / l o c a l / a u d i t / l o g s

18 175 18.4 case c a s e c a s e c a s e case i n 1 } 1... ; ; 2 2... e s a c c a s e i n * * [..] 18.4.1 case 1 5 c a s e A N S c a s e A N S c a s e c a s e *

176 s h e l l * 18.4.2 c a s e v t 100 v t 102 v t 100 v t 102 v t 100 v t 102 v t 100 v t T E R M * T E R M v t 100 c a s e T E R M * T E R M

18 177 18.4.3 y n c a s e y n Y y y e s c a s e N n n o 18.4.4 case c a s e $ # 1

178 s h e l l c a s e p a s s w d s t a r t s t o p h e l p 18.4.5 c a s e 234 4 53 6 55 4 54 c a s e

18 179 18.4.6 w h e n c a s e

180 s h e l l c a s e if then else 18.5 for f o r for i n d o d o n e 1 2

18 181 f o r s h e l l I n f o r i n 18.5.1 for 1 2 3 4 5 18.5.2 f o r orange red blue grey e c h o l o o p e c h o $ l o o p 18.5.3 for ls l s

182 s h e l l 18.5.4 for f o r i n for params in"$@" for params in"$*" i n f o r $ @ $ * i n $ @ f o r f i n d

18 183 f i n d - n a m e 18.5.5 for f o r f o 18.5.6 for f o r c p. b a k c p l s 18.5.7 L P S O l s c a t l s c a t t r.u C f o r l s

184 s h e l l 18.5.8 sed s e d. H O L D. m v m v 18.5.9 e x p r l s f o w c 18.5.10 for f o r w h o a w k f o r

18 185 18.5.11 for f o r f o for 1 in 1 d o for 2 in 2 d o 1... d o n e d o n e f o r A P P S S C R I P T S A P P S S C R I P T S t e e f o r S C R I P T S A P P S

186 s h e l l 18.6 until u n t i l u n t i w h i l e w h i l e u n t i l u n t i l u n t i l until 1... d o n e 18.6.1 until w h o r o o t I S - R O O T g r e p r o o t s i m o n r o o t s l e e p u n t i l

18 187 18.6.2 u n t i l / t m p / m o n i t o r. l c k p r o c e s s. m a i n p r o c e s s. m a i n L C K p r o c e s s. m a i n p r o c e s s p r o c e s s. m a i n L C K L C K L C K 18.6.3 u n t i l / l o g s $L O O K_O U T $ L O O K _ O U T a w k g r e p / l o g s 90 % 90 %

188 s h e l l 18.7 while w h i l e while d o d o n e 1 2... w h i l e d o 0 d o d o n e 0 18.7.1 while w h i l e C O U N T E R 5 C O U N T E R 0 C O U N T E R 1 1 5 18.7.2 while w h i l e F I L M < C t r l - D >

18 189 18.7.3 while w h i l e I D w h i l e $ L I N E. 18.7.4 IFS I F S I F S I F S t a b 3 N A M E D E P T I D e c h o t a b

190 s h e l l 18.7.5 w h i l e James Lenod James Lenod c a s e e x p r

18 191 18.7.6 S TAT G I F T G I F T e x p r e x p r L O O P TO TA L 0 I T E M S TO TA L I T E M S TOTAL

192 s h e l l e x p r e x p r e x p r TO TA L 0 e x p r

18 193 18.7.7 w h i l e w c 6 18.7.8 # w h i l e c a s e #

194 s h e l l # * * # 18.7.9

18 195 I T E M s e d w h i l e e x p r

196 s h e l l 18.7.10 while 5 w h i l e 3 4 m y f i l e. t x t m y f i l e. b a k w h i l e n u l l

18 197 18.8 break continue s h e l l break continue 18.8.1 break b r e a k b r e a k c a s e break 2 18.8.2 case 5 s h e l l b r e a k 18.8.3 continue c o n t i n u e b r e a k

198 s h e l l 18.8.4 Peter James 2 Peter James

18 199 18.9 w h i l e n u l l h i l e n u l l w h i l e c a s e / D D / M M / Y Y Y Y $ date +%d/%m/%y 3 2 / 0 5 / 1 9 9 9 h o s t n a m e - s w h i l e w h i l e while d o d o n e e c h o c a s e

200 s h e l l c a s e CAPS LOCK Q q 0 L I N U X BSD echo V echo "\007 the bell ring" e c h o t p u t t p u t c l e a r

18 201 18.10

19 shell s h e l l s h e l s h e l l { 1 }... 1... } f u n c t i o n f u n c t i o n {... } s h e l l s h e l l e c h o

19 shell 203 19.1 s h e l l h e l l o e c h o 19.2 h e l l o back from the function 19.3 $ 1, $ 2... $ 9 s h e l l _ F I L E N A M E _ f i l e n a m e 19.4 1) 2) r e t u r n 0 1

204 s h e l l r e t u r n Return 0 Return 1 19.5 i f 0 1 i f v a r i a b l e _ n a m e = f u n c t i o n _ n a m e f u n c t i o n _ n a m e v a r i a b l e _ n a m e 19.6 shell s h e l l #!/ b i n / s h f u n c t i o n s. m a i n s h e l l s e t s h e l l u n s e t s h e l l u n s e t s h e l l s h e l l u n s e t u n s e 19.7 s h e l l f u n c t i o n s. m a i n

19 shell 205 f i n d 1 $ 0 s h e l l s h - 19.8. / p a t h n a m e / f i l e n a m e s h e l l $. functions.main file not found $. /functions.main < > < > < > < > s h e l l 19.9 s e t s e s h e l l 19.10 shell f i n d i t

206 s h e l l 19.10.1 shell s h e l l u n s e t u n s e t unset function_name $ unset findit s e t 19.10.2 shell f u n c t i o n s. m a i n f o r $. /functions.main s e t s h e l l f o r f i n d i t

19 shell 207 19.10.3 1. a w k $ 1 a w k 1 _ L E T T E R S _ O N LY i f

208 s h e l l n a m e _ e r r o r $ @ F _ N A M E S _ N A M E w h i l e

19 shell 209 0 2. echo e c h o L I N U X B S D V e c h o e c h o r e a d L I N U X B S D e c h o - n L I N U X B S D e c h o e c h V \ C e c h o L I N U X - e s h e l l e c h o e c h o \ 007 V \ 007 L I N U X $ @ uni_prompt "\007 there goes the bell,what is your name:" What is your name: V L I N U X / B S D V \c z

210 s h e l l uni_prompts "\007 there goes the What bell is your name:" There goes the bell What is your name: 3. press any key to continue d d d d 1 m y f i l e dd if:/dev/zero of=myfile count=512 bs=2048 d d d d d s t t y d d d d

19 shell 211 4. i f 5. Y N c a s e

212 s h e l l $ 1 Y N c o n t i n u e _ p r o m p t

19 shell 213 $ 1 6. I D I D grep passwd grep /etc/passwd p a s s w d 5 p a s s w d I D g r e p w h o i s 7. v i n l n l

214 s h e l l n u m b e r _ f i l e s h e l l $ number_file myfile number_file $1 8. t r u p p e r $ @ s t r _ t o _ u p p e r $ 1

19 shell 215 9. is_upper s t r _ t o _ u p p e r i s _ u p p e r i f i s _ u p p e r i s _ u p p e r a w k i s _ l o w e r 10. s t r _ t o _ u p p e r s t r _ t o _ l o w e r

216 s h e l l L O W E R $ @ s t r _ t o _ l o w e r 11. 20 50 c h e c k _ l e n g t h

19 shell 217 N A M E 10 b r e a k w c w w c a w k w c 12. chop c h o p M Y D O C U M E N T. D O C M Y D U C U M E N T. D O C c h o p M Y D O C U M E N T. D O C 1 0 Chop

218 s h e l l C H O P P E D c h o p 13. MONTHS m o n t h s 3 03 M a r c h

19 shell 219 m o n t h s months 04 A p r i l J u n e 19.10.4 s h e l l 19.11 19.11.1

220 s h e l l e r r o r _ m s g 19.11.2 f u n c t i o n s. s h s h s h e l l

19 shell 221 f u n c t i o n s. s h.\<path to file> s h e l l s h e l

222 s h e l l 19.12 b a c k f u n c 1 _ C O D E _ C O D E c o m e t

19 shell 223 19.13

20 $ 1.. $ 9 $ # u s a g e shift getopts shift g e t o p t s u s a g e c a s e U N I X L I N U X

20 225 12 s h e l l s h i f t s h i f $ 1 $ 9 20.1 shift s h i f t w h i l e 20.1.1 shift s h i f t 20.1.2 e v a l eval echo \$$# s h i f t shift 'expr $# -2'

226 s h e l l 20.1.3 shift s h i f t t r -l -u s h i f t - l - u u s a g e c a s e s h i f t u s a g e c a s e c a s c a s * -* - p - q

20 227 * f o r - f c a s e - l - u T R C A S E E X T O P T. U C. L C y e s n o t r t r c a s e f o r

228 s h e l l

20 229 -l -c 23 -v 1 2 s h i f t g e t o p t s 20.2 getopts g e t o p t s g e t o p t 20.2.1 getopts g e t o p t s g e t o p t s a A L L t r u e h H E L P t r u e

230 s h e l l f F I L E t r u e v V E R B O S E t r u e f a l s e g e t o p t s getopts option_string variable while getopts ahfgv OPTION w h i l e o p t i o n _ s t r i n g 5 - a - h - f - g - v v a r i a b l e O P T I O N

20 231 20.2.2 getopts g e t o p t s o p t i o n _ s t r i n g g e t o p t s o p t i o n _ s t r i n g O P T I O N g e t o p t s O P T I O N 20.2.3 getopts g e t o p t s o p t i o n _ s t r i n g getopts ahfvc: OPTION a h f v c O P TA R G o p t i o n _ s t r i n g while getopts :ahfgvc: OPTION c a s e g e t o p t s

232 s h e l l - c 20.2.4 g e t o p t s g e t o p t s

20 233 d g e t o p t s O P TA R G g e t o p t s f o r t r- c a s e s h i f t g e t o p t s s h i f t 20.2.5 getopts t r- c a s e g e t o p t s g e t o p t s h i f t V E R B O S E V E R B O S E n o c a s e y e s i f / d e v / n u l l >/dev/null 2 >&1 V E R B O S E - v V E R B O S E m y f i l e tr-case -l -v myfile1 myfile2... tr-case -v -l myfile1 myfile2... g e t o p t s s h i f t

234 s h e l l U N I X L I N U X

20 235 - a - c - d - e - f - h - i - l - o - q - p -v 20.3 s h i f t g e t o p t s g e t o p t s s h i f t s h i f t $ 1.. $ 9 s h i f t

21 s h e l l t p u t tput t p u t GNU tput t p u t / e t c / t e r m i n f o / e t c / t e r m c a p t p u t 21.1 tput t p u t t p u $ tput init t p u t / 21.1.1 b e l b l i n k b o l d c i v i s c l e a r c n o r m c u p e l e l l s m s o r m s o s m u l r m u l s c rc s g r 0 r e v x y

21 237 21.1.2 c o l s i t l i n e s t a b 21.1.3 t p u t c h t s h s 21.2 tput t p u t t p u 21.2.1 tput t p u t variable_name='tput name' 21.2.2 i f t p u t 21.2.3 tput tput bel c l

238 s h e l l 21.2.4 1) 2) tput civis 25 l l 25 h [ U N I X L I N U X e c h o \ 033 \ e c h o @ echo @ e c h o - e \ 100 v echo \ 1 0 0 c l e a r h o m e V T E S C I J e c h o e c h o ' < CT R L - V> hit the<escape> key then [?25h' < C T R L - V >,

21 239 21.2.5 t p u t cup r c r c

240 s h e l l 21.2.6 t p u t t p u t 2 10 centertxt 15 THE MAIN EVENT centertxt 15 $1 21.2.7 t p u t t e r m i n f o t p u t

21 241 i n f o c m p t e r m i n f o $ infocmp $TERM t e r m p u t 21.2.8 c a t F 1 cat -v < C t r l - c > c a t F 1 ^ [ O P ] F 2 ([ O Q ]) [ ^ [[ A ] F 1 F 2 c a t

242 s h e l l 21.2.9 A N S I 1. 3 0 3 4 3 1 3 5 3 2 3 6 3 3 3 7 2. 4 0 4 4 4 1 4 5 4 2 4 6 4 3 4 7

21 243 <ESCAPE> [background_number;foreground_number m 21.2.10 e c h o e c h o < C t r l - v > < E S C A P E > [ 40 32 m e c h o c a s e r e d - y e l l o w colour red-yellow e c h o. p r o f i l e 2 1-2

244 s h e l l 21-1 tput 21-1

21 245

246 s h e l l 21.2.11 w h i l e r e a d _ c h a r t r a p 2 3 1 5 p r i v. u s e r r o o t d a v e m a t t y p e t e r l o u i s e

21 247 F O U N D U S E R U S E R w h o a m i c o n t i n u e t e s t 1 0 p a s s w d 21-2

248 s h e l l R e s t r i c t 2 1-2 d a v e q Q

21 249

250 s h e l l

21 251 p r o f i l e e x e c U N I X L I N U X s h e l l 21.3 t p u t

22 D B F I L E 1 0 2 0 2 0 - IT <Staff number>:<first name>:<second name>:<department> t r a p 2 3 1 5 22.1 1) 2)

22 253 r e a d _ a _ c h a r

254 s h e l l g r e p g r e p _ C O D E a w k 0 g r e p $ _ C O D E \ >

22 255 w h i l e w h i l if ["$NUM"!=""] i f t h e n e l s e Staff Number:No Input Detected This Field Requires a Number t h e n a _ n u m b e r 0 1 NU M_ PA S S 0 1 l e n g t h _ c h e c k 10 10 0 1 L E N _ PA S S 0 1 c h e c k _ d u p l i c a t e D U P L I C AT E 0 A N D t h e n w h i l e b r e a k Staff Number : Non_Numeric or Too Many Numbers In Field 2 3 c h a r a c t e r s

256 s h e l l c a s e 5 c a s e c o n t i n u e _ p r o m p t Y N Y N N i f w h i l e Y echo "$NUM:$F_NAME:$S_NAME:$DEPART">>$DBFILE s l e e p 1 s D B F I L E

22 257 D B F I L E

258 s h e l l

22 259

260 s h e l l

22 261

262 s h e l l 22.2 1) 2) 3) 4) g r e p a w k 100 a w k a w k g r e p a w k g r e p D B F I L E a w k I F S I F S I F S S A V E D I F S = $ I F S I F S = : I F S I F S = $ S A V E D I F S

22 263 g e t _ r e c q if ["$STR"!=""] t h e n [-2 $STR] 0 b r e a k n o

264 s h e l l grep -v S T R S T R g r e p D B F I L E D B F I L E

22 265

266 s h e l l 22.3 { d e f a u l t _ v a r i a b l e = v a r i a b l e }

22 267 grep -v g r e p grep -v $CODE $DBFILE >$HOLD1 D B F I L E D B F I L E

268 s h e l l

22 269

270 s h e l l 22.4 c a t a w k

22 271

272 s h e l l

22 273 22.5

23 s h e l l set i f f i s h e l l s h e l l 23.1 23.1.1 f o r w h i l e u n t i l c a s e d o n e w h i l w h i l e d o 23.1.2 s h e l l v i v i set nu v i < E S C > set nu <return> s h e l l 23.1.3 - e q

23 275 [: missing ']' 23.1.4 23.1.5 for f o r $ 23.1.6 echo e c h o e c h e c h o e c h o 23.2 set s e t s e t set -n set -v set -x s e t + - + - s e t f o r set -x

276 s h e l l s e t 23.3 s e t e c h o

24 shell s h e l l s h e l l Bourne shell / b i n u s r / b i n Bourne shell c d p w d / b i n / p w d 24.1 shell 2 4-1 24-1 t r u e. s h e l l b r e a k c d c o n t i n u e e c h o e v a l e x e c exit e x p o r t p w d r e a d r e a d o n l y r e t u r n s e t s h i f t test t i m e s t r a p u l i m i t u m a s k u n s e t w a i t f o r w h i l e u n t i l c a s e s h e l l s h e l l s h e l l s h e l l s h e l l s h e l l 24.1.1 pwd

278 s h e l l $ pwd / t m p 24.1.2 set s h e l l s e t s e t s e t set param1 param2.. a c c o u n t s. d o c a c c o u n t s. b a k s e t 24.1.3 times t i m e s s h e l l t i m e s 24.1.4 type t y p e t y p

24 s h e l l 279 24.1.5 ulimit u l i m i t s h e l l / e t c / p r o f i l e s h e l l. p r o f i l e u l i m i t ulimit options u l i m i t u l i m i t - a - c - f 0 24.1.6 wait w a i t w a i I D $ wait 24.2 s h e l l

shell 25 << w h i l e < < < < ftp command <<word t e x t w o r d < < s h e l l < < s h e l l ( ) < < 25.1 $ cat >> myfile <<NEWFILE N E W F I L E m y f i l e t a b s h e l l < < - cat >> myfile <<- NEWFILE... 25.2 v i Q U I C K D O C

s h e l l 25.3 < < c r o n < < s y b _ b a c k u p 2 3 Y 1) s y b _ b a c k u p 2) 2 3) 3 4) Y s y b _ b a c k u p

25 s y b _ b a c k u p >>$log_f 2>&1 $ l o g _ f / l o g s / s q l. b a c k u p. l o g < < M AY D AY s y b _ b a c k u p M AY D AY < < 25.4 ftp < < f t p f t p a n o n y m o u s f t p 1) 2) A S C I I 3) 4) t r a c e r o u t e t r a c e r o u t e f t p

s h e l l / t m p / t m. f t p

25

s h e l l f t p < < ftp -i -n u s e r $ U S E R @ T H I S H O S T d a v e @ b u m p e r D E S T _ H O S T F I L E N A M E f t p D E S T _ H O S T m y _ f a v o u r i t e _ h o s t 25.5 s h e l l < < < < select into

25 < < f o r < < s q l < < s h e l l s h e l l M AY D AY

s h e l l 25.6 < < < f t p < <

26 shell t r a p e v a l l o g g e r 26.1 c a t 26.1.1 date d a t e date option + %format + h h : m m

s h e l l d d m m y y d d h h m m 26.1.2 $ $ $ $ $ $ S h e l l $ $

2 6 rm /tmp/*.$$ s h e l l rm /tmp/*.408 26.2 1 S I G H U P 2 S I G I N T < C T R L - C > 3 S I G Q U I T 9 S I G K I L L 11 S I G S E G V 1 5 S I G T E R M 0. l o g o u t s h e l l 0 e x i t < C T R L - D > kill [-signal no: signal name] process ID k i l l 15

s h e l l 26.2.1 1 D N S n a m e d kill -1 1 N a m e d m o n _ w e b 9 p s ps -ef ps xa kill -9 157 kill -s SIGKILL 157 - s kill SIGKILL 157 g r e p kill -9

2 6 26.2.2 9 s h e l l 1 2 3 1 5 1 2

s h e l l 3 t r a p 26.3 trap t r a p trap name signal(s) n a m e n a m N a m e S i g n a l 1) 2) 3) t r a p trap "" 2 3 trap"commands" 2 3 trap 2 3 2 3 2 3 c o m m a n d s 2 3 26.3.1 < C t r l - C > 2 t r a p trap "do_something" signal no:(s)

2 6 trap "my_exit" 2 t r a p 2 m y _ e x i t m y _ e x i t 2 $ L O O P < C t r l - C > 2 26.3.2 d f p s H O L D 1. $ $ H O L D 2. $ $ $ $ < C T R L - C >

s h e l l 2 3 < C T R L - C > 2 c a s e 1 2 c a s e c a s e

2 6 < C T R L - C > 26.3.3 l o c k i t w h i l e t r a p 2 3 1 5 $ stty sane

s h e l l l o c k i t 26.3.4 / e t c / p r o f i l e t r a p 1 2 3 1 5

2 6 t r a p 9 trap""signal no:(s) trap"do something" signal no:(s) trap ""1 2 3 15 trap"my_exit" 1 2 3 15 m y _ e x i t w h i l e t r a p 6 s l e e p

s h e l l < C t r l - C > t r a p < C t r l - C > m y _ e x i t t r a p 26.4 eval e v a l e v a l e v a l 26.4.1 t e s t f cat testf M Y F I L E e c h o cat testf M Y F I L E $ MYFILE= cat testf

2 6 e c h o t e s t f e v a l e v a l e v a l cat testf C AT _ PA S S W D cat /etc/passwd more eval e v a l e v a l $ $ # s h e l l 26.4.2 d a t a e v a l

s h e l l d a t a P C 486 N A M E T Y P E E v a l N A M E T Y P E P C 486 P C 486 e v a l e v a l 26.5 logger m e s s a g e s / v a r / a d m / v a r / l o g s y s l o g m e s s a g e s / e t c / s y s l o g. c o n f U N I X L I N U X l o g g e r / v a r / a d m / m e s s a g e s l o g g e r logger -p -I message

2 6 - p - i 26.5.1 logger m e s s a g e c r o n t a b 30 $ test_logger m e s s a g e 26.5.2 logger l o g g e r 2 3 1 5

s h e l l l o g g e r t t y 0 t t y 02 / e t c / p r o f i l e

2 6 l o g g e r 26.6

27 500 p i n g a l l / e t c / h o s t s p i n g b a c k u p _ g e n d e l. l i n e s s e d a c c e s s _ d e n y l o g r o l l n f s d o w n u n m o u n t n f s 27.1 pingall p i n g a l l / e t c / h o s t s p i n g / e t c / h o s t s # w h i l e a w k A D D R f o r p i n g 27.2 backup_gen

27 b a c k u p _ g e n b a c k u p. d e f a u l t s [ ] [ r m t 0 ] r m t 1 r m t 3 [ ] [ ] s y b a s e f i n d c p i o

s h e l l

27

s h e l l backup.defaults continue_prompt

27

s h e l l 27.3 del.lines s e d s e d s e d s e d $ $ s h i f t w h i l e del.lines -help

27 27.4 access.deny / e t c / n o l o g i n / e t c t o u c h n o l o g i n r o o t / e t c / p r o f i l e / e t c n o l o g i n

s h e l l rm /etc/nologin / e t c / p a s s w d * L I N U X l o g i n. a c c e s s d e n y. a c c e s s / e t c / p r o f i l e l o c k o u t. u s e r s a l l r o o t l o c k o u t. u s e r s t r a p l o c k o u t. u s e r s a l l a l l a l l r o o t g r e p a l l \ > get_users l o c k o u t. u s e r s # r o o t r o o L O G N A M E N A M E S N A M E S l o c k o u t. u s e r s 40 / e t c / p r o f i l e. /apps/bin/deny.access / a p p s / b i n

27 l o c k o u t. u s e r s / a p p s / e t c s e t l o c k o u t. u s e r s u n s e t u n s e t / e t c / p r o f i l e unset getusers

s h e l l 27.5 logroll c r o n 16 B L O C K _ L I M I T 8 4 K L O G S f o r d u B L O C K _ L I M I T 0 c r o n

27 27.6 nfsdown n f s n f s n f s L I S T n f s f o r g r e p d f n f s n f m o u n t machine: remote_directory N F S _ M A C H I N E u m o u n t 27.7

28 L I N U X L I N U V U N I X r c. s c r i p t s r c. s c r i p t s i n i t t a b r c. s c r i p t s t a r t s t o p r c. s c r i p t r c. s c r i p t s h e l l 28.1 r c. s c r i p t s ( ) / e t c / r c N. d / e t c / r c. d / r c N. d N 7 r c N. d 0 6 r c S. d L I N U X

28 c d r c N. d r c. s c r i p t s 28.2 s h e l l r c. s c r i p t s run level L I N U X $ runlevel 2 3 3 28.3 inittab i n i t i n i t t a b / e t c i n i t i n i t t a b i d : r s t a r t : a c t i o n : p r o c e s s i d r s t a r t a c t i o n i n i t p r o c e s s

s h e l l w a i t r e s p a w n w a i t r e s p a w n p r o c e s s i n i t t a b 3 10 1 6 15:5:wait:/etc/rc.d/rc 5 5 5 / e t c / r c. d / r c / e t c / r c. d / r c / e t c / r c. d / r c 5. d 2 3 4 5 1 s t t y S 1 m i n g e t t y v t 100 28.4 i n i t / e t c / r c. d / r c / e t c / r c. i n i t r c r c. i n i t f o r K s t o p S s t a r t r c N. d

28 / u s r / s b i n / i n i t. d / e t c / i n i t. d L I N U X / e t c / r c. d / i n i t. d r c. < > r c run command r u n c o n t r o l real crucial r c. s c r i p t s rc.name stop rc.name start r e s t a r t s t a t u s r c N. d 28.4.1 ( 28-1 ) 28-1 0 1 2 3 3 4 5 U N I X X - w i n d o w s 6 28.4.2 r c N. d S n n n. s c r i p t _ n a m e K n n n. s c r i p t _ n a m e S K n n 00 9 9 000 9 99

s h e l l r c 3. d S 45. m y s c r i p t r c 2. d S 45. m y s c r i p t s c r i p t _ n a m e / u s r / s b i n / i n i t. d / e t c / r c. d / e t c / i n i t. d i n i t K K23,myscript K12.named L I N U X K 28.4.3 ( )/ e t c / i n i t. d / u s r / s b i n / i n i t. d / e t c / r c. d r c N. d r c. a u d i t 3 5 4 6 2 1 r c N. d 35 c a s e s t a r t s t o p

28 LINUX L I N U X s t a r t s t o p i n i t. d r c N. d / e t c / r c. d / e t c / r c. d / i n i t. S ls -l / e t c / i n i t. d / r c. a u d i t ( r c 4. d r c 5. d ) ( 6 ) 2 1 4 5 28.5 inittab i n i t t a b i n i t t a b

s h e l l 3 i n i t t a b $ cp /etc/initab /etc/inittab.bak i n i t t a b r c. d i s k c h e c k e r 3 / u s r / l o c a l / e t c / r c. d i s k c h e c k e r 28.6 / e t c / i n i t t a b r c. l o c a l / e t c i n i t t a b / b i n ( / u s r / s b i n ) s h u t d o w n 28.7

29 cgi P C We b s h e l l c g i c g i (Server Side Includes,SSI) get post We b c g i We b We b ( a p a c h e C e r n ) ( N e t s c a p e Internet Explorer ) c g i c g We b 20 We b apache We b N e t s c a p e H T M L We b H T M L 29.1 Web We b H T M L We b H T M L We b We b We b c g i 29.2 cgi c g i c g i P e r l

s h e l l s h e l l 29-1 Web Web apache? cgi 29-1 cgi 29.3 Web ( U R L ) We b U R L h t t p f t p m a i l t o f i l e t e l n e t n e w s h t t p ( ) D N S I P T C P 80 We b i n d e x. h t m l U R L h t t p : / / l o c a l h o s t / i n d e x. h t m l i n d e x. h t m l We b U R L h t t p : / / l o c a l h o s t / 29.4 cgi HTM We b U R L c g i - b i n c g i c g i c g i We b H T M L H T M L We b 29-1 H T M L 29.4.1 cgi c g i We b c g i - b i n s r m. c o n f S c r i p t A l i a s c g i. c g We b h t m l h t d o c s. h t m l chmod 755 script.cgi We b n o b o d y h t t p d. c o n f

29 We b p a s s w d n o b o d y n o b o d / e t c / p a s s w d * 29-1 H T M L < H T M L > < / H T M L > H T M L < H E A D > < / H E A D > < T I T L E > < / T I T L E > < B O D Y > < / B O D Y > < H n > < / H n > 1 < P > < / P > < B R > < H R > < P R E > < / P R E > < B > < / B > < I > < / I > < O L > < / O L > <A HREF=url>link</A> < F O R M > < / F O R M > M E T H O D A C T I O N p o s t g e t < I N P U T... > N A M E S I Z E T Y P E < S E L E C T... > N A M E S I Z E <OPTION VA L U E > < / S E L E C T > N A M E a p a c h e We b / e t c / h t t p d / l o g s / u s r / l o c a l / a p a c h e / l o g s We b c g i c g i f i r s t p a g e. c g c g i - b i n 755

s h e l l s h e l l e c h o M I M E e c h o M I M E c g i e c h o < H T M L > H T M L H T M L < H 1 > < H n > < H 6 < H 2 > < C E N T E R > Stand-By To S t a n d - To < / H T M L > U R L h t t p : / / y o u r _ s e r v e r / c g i - b i n / f i r s t p a g e. c g i y o u r _ s e r v e r D N S I n t e r n e t 2 9-2 29-2 firstpage 29.4.2 shell s h e l l w h o w c

29 U S E R S i f 10 < P R E > d f e c h o < P R E > < P R E > U R L h t t p : / / y o u r _ s e r v e r / c g i - b i n / p a g e t w o. c g i y o u r _ s e r v e r 2 9-3 29-3 pagetwo.cgi

s h e l l 29.4.3 SSI c g i We b c g i c g i H T M L c g i ( S S I ) S S I S S I S S I s e r v e r- p a s s e d a p a c h e We b kill -1 S S I. s h t m l. h t m 29.4.4 n c g i - b i n h i t c o u n t. c g i../ c d i - b i n / c o u n t e r a c c e s s 1../ c g i - b i n / c o u n t e r c o u n t e r 1 c o u n t e r 1 ( ) $ chmod 666 counter We b ( H T M L h t d o c s h t m l ). s h t m l. s h t m

29 S S I L A S T _ M O D I F I E D a p a c h e We b ( w w w. a p a c h e. o rg ) S S I S S I <!--#command argument="value"--> c g i h i t c o u n t e x e c c g i v a l u e i n d e x. h t m l U R L i n d e x. h t m l 29-4

s h e l l s r m. c o n f D i r e c t o r y I n d e x i n d e x. h t m l We b U R L h t t p : / / < s e r v e r _ n a m e > / m a i n. s h t m l h t t p : / / < s e r v e r _ n a m e > 2 9-4 L A S T _ M O D I F I E D c r o n c o u n t e r 1 29.4.5 Web c g i e n v s e t m a i n. s h t m l c g i <A HREF="/cgi-bin/printenv.cgi">Environment</A> A HREF E n v i r o n m e n t < / A > m a i n. s h t m l p r i n t e n v. c g i e n v < P R E >

29 2 9-5 29-5 29-6

s h e l l ( 29-6 ) 29.4.6 2 9-2 c g i e n v s e t 29-2 cgi We b DOCUMENT ROOT G AT E WAY _ I N T E R FA C E H T T P _ A C C E P T H T T P _ C O N N E C T I O N H T T P _ H O S T H T T P _ U S E R _ A G E N T R E M O T E _ H O S T R E M O T E _ A D D R * R E Q U E S T _ M E T H O D S C R I P T _ F I L E N A M E S C R I P T _ N A M E S E RV E R _ A D M I N S E RV E R _ N A M E S E RV E R _ P R O TO C O L S E RV E R _ S O F T WA R E Q U E RY _ S T R I N G C O N T E N T _ T Y P E C O N T E N T _ L E N G T H We b H T M L c g i M I M E H T T P I P c g i c g i We b D N S I P We b g e t M I M E p o s t * I n t e r n e t c g i

29 29.5 get post c g i c g i g e t p o s t 29.5.1 get g e t g e t H T M L U R L Q U E RY _ S T R I N G R E Q U E S T _ M E T H O D 1. m a i n. s h t m l b o o k a. c g i m a i n. s h t m l b o o k a. c g i c g i - b i n

s h e l l b o o k a _ r e s u l l t. c g i g e t 30 c o n t a c t f i l m a c t o r v i e w _ c i n e v i e w _ v i d o n ( 4 30 ) t e x t a r e a s u b m i t c l e a r c g i b o o k a _ r e s u l t. c g i c g i - b i n Q U E RY _ S T R I N G R E Q U E S T _ M E T H O D Q U E RY _ S T R I N G

29 b o o k a. c g i R E Q U E S T _ M E T H O D get 29-7 ( 29-8 ) 29-9 Q U E RY _ S T R I N G 29-7 get cgi 29-8

s h e l l 29-9 Q U E RY _ S T R I N G c o n t a c t f i l m a c t o r v i e w _ c i n e v i e w _ v i d 2. David Ta n s l e y The Sound Of Music Bruce Wi l l i s o n o n t e x t a r e a! " % $ % ^ * ^ & * ( ) * ( ) ( * H o w s that!! Q U E RY _ S T R I N G + & = x y x 16 A S C I I Q U E RY _ S T R I N G t e x t a r e a c g i x y ( x y 1 6 ) A S C I I 16 & + = ( ) A S C I I 127 ( 29 16

29 & + = x y A S C I I e v a l p r i n t f

s h e l l p r i n t f e c h o 16 p r i n t f \ n Q U E RY _ S T R I N G 16 x y s e d \ x n n ( n n 1 6 ) p r i n t f c o n v. c g i c g i - b i n b o o k a. c g i c o n v. c g i b o o k a _ r e s u l t. c g i <FORM action="/cgi-bin/conv.cgi" METHOD=GET> c o n v. c g i 29-10 29-10 g e t g e U R L U R L Q U E RY _ S T R I N G c g i p o s t p o s 29.5.2 post p o s t g e t p o s

29 p o s t g e p o s <FORM action"/cgi-bin/conv.cgi" METHOD=POST> C O N T E N T _ L E N G T H p o s t g e t C O N T E N T _ L E N G T H c a t c o n v. c g i g e t p o s c a t - c a t Q U E RY _ S T R I N G p o s t c a t g e t c g i b o o k a. c g i <FORM action="/cgi-bin/conv.cgi"method=get> <FORM action="/cgi-bin/conv.cgi"method=post> c o n v. c g i

s h e l l p r i n t f e c h o p r i n t f p o s t h t t p : / / < s e r v e r _ n a m e > / c g i - b i n / b o o k a. c g i 2 9-11 29-12

29 29-11 post cgi 3. c g i 29-12 post Wonder Gifts

s h e l l 1998 1 3

29 d e p t q t r s t d o u t p r i n t e r s c r e e n b o t h ( C H E C K E D )

s h e l l p o s t 16 ( ) p r i n t f q t r _ 1998. t x t w h i l e D E P T Y E A R Q P 1 P 2 P 3 P 4 $ d e p t ( ) D E P T $ q t r ( ) Q U R L U R L ( ) h t t p : / / < s e r v e r _ n a m e > / c g i - b i n / g i f t s. c g i 29-13 29-13

29 29-14 29-14 29.5.3 c g i l i s t We b t e m p w h i l e ( ) echo "<OPTION>$LINE" m e n u _ s e l e c t i o n

s h e l l 29.5.4 c g i 60 d f s p a c e. c g i <meta http-equiv="refresh" content=60;url=http:/linux.pc/cgib i n / d f s p a c e. c g i " > R e f r e s h We b c o n t e n t = 60 U R L o n o ff d f c e l l s p a c i n g b o r d e r c o l s d f s e d a w k 5 6 p e r c e n t m o u n t T R T D 60

29 U R L U R h t t p : / / < s e r v e r _ n a m e > / c g i - b i n / d f s p a c e. c g i 29-15 ( ) 29-15 df 29.6 c g i H T M L H T M L