UNIXe  ""  1. . . . . . . . . 2. . . . . . . . . . . . . . . . . . . . 2.1. . . . . . . . . . . . . . . 2.2. (UID) - (GID) . . . . . . . . . . . . . . 3. UNIX . . . . . . . . . . . . . . . . . . . . . 3.1. . . 3.2. - . . . . . . . . . . . . . . 3.3. . . . . . . . 3.4. . . . . . . 3.5. . . 3.6. - . . . . . . . . . . . . . . . . 3.7. - . . . . . . . . . . . . . . . . 3.8. 3.9. . . . . . . . . . . . . 3.10. . . . . . . . . . . . . . . . . 3.11. . . . . . 3.12. . . . . . . . . . . . . 3.13. . . . . . . . . 3.14. . . . . . . 3.15. / . . . . . . . 3.16 , . . . . . . . . . . . . . . . . . . . .  * 1. *  - UNIX. UNIX - , , . - . , , . , shell, , - . UNIX ( shell) - . , , - , shell . shell - : ( - fork), , - , : - -- . - -: , , . - - - ( - wait), - . - exec, - UNIX , , . , -. , , shell (-) - -, . , - "- " ( exit). - - . , , " ", .. , - . - - -, - , - - . - - - - . - , PID (process ID). - - PPID (parent PID). , ps (. 3.14).  * 2. *  , - . , , , .. 2.1.  , , - fork, . -- , . - -, -. . 2.2. (UID) (GID) , , ( id (. 3.12)). . , - , - . , - , . - , - , . . , - (. mail, rmdir) - , , , , , - .  * 3. UNIX *  awk - bc - chmod - cmp - comm - dc - - echo - - factor - file - find - grep - id - - kill - ps - sort - / wc - , 3.1. awk -  : awk [ -Fc ] [ -f ] [ <> ] [ <> ] [ <> ] awk , - - , <>. - <>, progfile awk -f progfile [ <> ] , ('). awk - x=... y=... .. . - . . - , . "-" . awk , . , awk - . , - RS. , . . - , FS c -Fc. $1, $2, ...; $0 - . , . , <>, . - , , . <-> : <> { <> } . . - . , , . , . - , . , , . . - , , , . : if ( <> ) <> [ else <> ] while ( <> ) <> for ( <>; <>; <> ) <> break continue [ <> ] ... <> = <> print [ < > ] [ > <> ] printf <> [ , < > ] [ > <> ] next ( ) exit ( ) , . < > . +, -, *, /, % ( ). C: ++, --, +=, -=, *=, /=, %=. . (- x[i]) . - . - ("). print ( , '> <>'), . printf , ( printf C). length - , ; , - . : exp, log, sqrt int (int ). substr(s, m, n) n- s, m. sprintf(<>, <>, <>, ...) (. printf) . - ( !, || ,&& ) (. grep (egrep)), (/), (. ). - . - . , ; , , , . - - : <> <_> <_> <> <_> <> <_> - C, <_> - ~ () !~ ( ). <> - , . - BEGIN END. , c -Fc, BEGIN { FS = c } : NF - NR - FILENAME- , - OFS - ( - ) ORS - ( ) OFMT - ( %.6g) . 1) first, 72 awk 'length > 72' first 2) second awk '{ print $2, $1 }' second 3) , third, - : prog: { s += $1 } END { print "sum is", s, "average is", s/NR } : awk -f prog third : awk '{ s += $1 } END { print "sum -",s,"average -",s/NR }' third 4) fourth awk '{ for (i = NF; i > 0; --i) print $i }' fourth 5) fifth, start/stop awk '/start/,/stop/' fifth 6) sixth, - awk '$1 != prev { print; prev = $1 }' sixth 7) seventh, , , "Page" program: /Page/ { $2 = n++; } { print } : awk -f program n=5 seventh 3.2. bc -  : bc [ -c ] [ -l ] [ <> ... ] bc - C- , - . , - . -l . bc. L [a-z], E - , S - . , /* */. : L : L [ E ] "ibase","obase","scale" , - ( E ) sqrt ( E ) length ( E ) scale ( E ) - L ( E, ..., E ) + - * / % ^ (% - , ^ - ) ++ -- ( 1; - ) == <= >= != <> = =+ =- =* =/ =% E { S; ... ; S } if ( E ) S while ( E ) S for ( E; E; E ) S break quit define L ( L, ..., L ) { auto L, ..., L S; ...; S return ( E ) } , -l : s(x) - sin(x) c(x) - cos(x) e(x) - exp(x) l(x) - ln(x) a(x) - arctan(x) j(n,x) - . , , , . ; . scale . ibase obase - . , . - . , "auto", . - - , . bc - dc, - , -c ( ). . sqrt(x) 10 . /* */ scale = 20 /* */ define r(a) { auto x,y y = a + 1 x = y + 1 while ( y < x ) { x = y y = 0.5 * ( x + a / x ) } return (y) } /* */ for ( i = 1; i <= 10; i++ ) r(i) /* */ quit . for E. Quit , . 3.3. chmod -  : chmod . . - , : 04000 - UID - UID 02000 - GID - GID 00400 - 00200 - 00100 - 00040 - 00020 - 00010 - 00004 - 00002 - 00001 - , , , , 0400, 0200, 0040 0004. - : chmod 644 file : [ <> ] <> <> <> u (), g () o (). <> a, ugo. <> : + - , - - - , = - - . <> - r (), w (), x (), s ( UID GID). <> <> = . , , , <> , - . , chmod u+w,go+x file , - . - ( ). ( ). ls -l file ( UID GID s - x: s, x, S - ). . file : -rw-rw-rw-, . 1) chmod o-w file ( -rw-rw-r-- ) 2) chmod +x file ( -rwxrwxr-x ) 3) , - chmod g=+r file ( -rwx-w-r-x ) 4) UID UID chmod u+s file ( -rws-w-r-x ) 3.4. cmp -  : cmp [-l] [-s] file1 file2 file1 file2 ( file1 - -, ). , cmp , ; - , , . - , : cmp: EOF on < > < > - . : -l - () - () -s - , : - 0, - 1, - 2. 3.5. comm -  : comm [ - [ 123 ] ] file1 file2 Comm file1 file2 : 1. , file1 2. , file2 3. , - . 1,2 3 . , comm -12 , ; comm -23 - file1, file2; comm -123 . 3.6. dc -  : dc [ ] dc - . , , , . dc - , . , , . bc, dc, C- (. 3.2). dc : <> - . <> - - 0-9. (_) . <> . +-/*%^ - (+), (-), (*), (%) , , . . . sx - x, x - . S, x . lx - , x, . x . - . L, - - . d - p - ( ). P . f - . q - . x - dc X - [ ... ] - , , . x =x - - . , - x dc . v - . , . ! - shell c - i - - . I - . o - - . O - - . k - - : , , . z - Z - ( - ). ? - - . . 10 n! [la1+dsa*pla10>y]sy 0sa1 lyx x is unimplemented - x - stack empty - , - Out of pushdown - Nesting Depth - 3.7. echo -  echo , . - , : \b - \c - \f - \n - \r - \\ - \0xx - , 0 - , ASCII 3.8.  : factor [ <> ] . - 2 (~ 7.2*10). : Ouch! . - , . 3.9. file -  : file [ -f ffile ] <> ... file , , . , file 512 - . -f - , . 3.10. find -  : find < > <> Find - , , - <>, - . n - , +n , n, -n - , n. -name <> , <> -perm onum , onum (. chmod) -type c , c, c - b, c, d, p, f - - - , , (pipe) -links n , n -user uname , UID uname -group gname , GID gname -size n[c] , n ( 512 ). c, -atime n , n -mtime n , - n -ctime n , n -exec cmd , cmd - . Cmd - , . {} -ok cmd , exec, , cmd - cmd y -print ; () , - ( ) - ( ): 1) (! - NOT) 2) ( AND, ) 3) (- - OR) . a.out *.o, : find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \; 3.11. grep -  - : grep, egrep fgrep. : grep [ ] [ ] egrep [ ] [ ] [ ] fgrep [ ] [ ] [ ] ( - ) , . , . grep (. "- shell); . egrep - . fgrep - ; fgrep . : -v , -x ( fgrep) -c -i - -l , - -n -b , . - -s , "" " " ( grep) -e , <>, , <> - ( - grep) -f (egrep) (fgrep) , , , . $, *, [, ^, |, (, ) \ <> '...'. fgrep , <>. egrep , shell (.) ( \( \) ), , : 1. , +, - . 2. , ?, - . 3. , | , , . 4. . egrep [a-z]. , , 0, - - 1, , , ( ) - 2. 3.12. id -  : id id , - UID, GID . 3.13. kill -  : kill [ -< > ] pid ... kill 15 . - , . ps (. 3.14). shell . , , . , 15 . kill -9 ... , , , . ( . " shell") 3.14. ps -  : ps [ ] ps . , , . ps : -e -f -l -t <> , <> ( <>, tty console) -p <> -u , UID -g , GID ; l f , ; all , - . F (l) (), - : 01 02 04 - 10 20 40 S (l) : 0 S W R I Z T (stopped) X UID (f,l) UID ; - -f PID (all) PPID (f,l) - C (f,l) STIME (f) PRI (l) ; NI (l) ADDR (l) ( ), , SZ (l) WCHAN (l) , - ; TTY (all) , TIME (all) CMD (all) ; -f, - , , . -f ps - , - . , - . 3.15. sort - /  : sort [ - cmu ] [ -ooutput ] [ -ykmem ] [ -zrecsz ] [ -dfiMnr ] [ -btx ] [ +pos1 [ -pos2 ]] [ files ] Sort . , -, . , . , ; - ASCII. : -c , -m ; -u -ooutput , ; . -o output -ykmem sort - ; kmem . - , - . , -y0 . - , -y ( ) -zrecsz , , - sort . recsz . : -d "" : , -f -i , 040-0176 -M , "JAN" < "FEB" < ... < "DEC". "JAN". -b (. ) -n , , -, - , . -b (. ) -r +pos1 -pos2 , - pos1 pos2. -pos2 , . pos1 pos2 - - , . , - . - (, - ). - : -tx x; x