Shell , ; . =, , S2 = '<'. $. :
- $n, n - ;
- , ;
- #? -! $ , , , Shell.
. Shell :
z=1000
= $z
h $
1000
x z.
. $n, n - , , . ,
t text_1 text_2...text_9
$1...$9. S0. $0 - t, $1 - text_1, $2 - text_2 .. set, :
Set arg_1 arg_2... arg_9
$1 arg_1, $2 - arg_2 ..
echo, :
echo $1 $2 $9
arg_1 arg_2 arg_9
( ) *. :
echo $*
arg_2 arg_3... arg_10 arg_11 arg_12
Shell . Shell , .
. -? # $! Shell. echo :
- ( set);
# , - ;
? ;
$ PID;
! PID .
. :
cd [dir] - ;
exec [cmd [arg...]] < > - , cmd arg, .
umask [ -o | -s] [nnn] - ( , nnn: 3 , ). nnn , . -o , -s - ;
|
|
set, unset - , ;
eval [ -arg] - ;
sh < filename. sh > filename.sh;
exit [n] - , , , ;
trap [cmd] [cond] - , : cmd - ; cond=0 EXIT - cmd ; cond=ERR - cmd ; cond - , cmd ;
export [name [=word]...] - . export , name ;
wait [n] - . , . n, wait n;
read name - , name.
true false p: true - , 0; false - , , . while until if. LINUX .
if . true, Shell if , false, . if:
if <>
Then
List1
Else
List2
Fi
test () if . test. Test , , . , , .
:
test [ -rwfds] file
-r ( 0);
-w ;
-f ;
-d ;
-s .
test , , , . :
-eq =
-ne <> B
test A -ge B >=
-le <=
-gt >
-lt <
, .
test :
! - , , if test true if test! false;
|
|
o - "" (or) true, true;
a - "" (and) true, true.
while true while false. while () , , while true false. p while true:
While list1
Do
List2
Done
list1 list2 - . While , while, 0, , do done. while false :
Until list1
Do
List2
Done
do done . ( ). break . break 2 (break 2), .
continue while.
for:
for name in [wordlist]
Do
List
Done
name - ; wordlist - ; list - . name wordlist, , do done. name wordlist list. , wordlist.
case. case . :
case <string> in
s1) <list1>;;
s2) <list2>;;
.
.
.
sn) <listn>;;
*) <list>
Esac
3 list1, list2... listn - . string s1, s2... sk... sn. , sk ;;. :
echo -n 'Please, write down your age'
Read age
case $age in
test $age -le 20) echo 'you are so young';;
test $age -le 40) echo 'you are still young';;
test $age -le 70) echo 'you are too young';;
*)echo 'Please, write down once more'
Esac
* .
2.
:
1. , ( ). .
2. , . , , , .
3. , . , , , .
4. , , .
5. , , .
|
|
6. , , . .
7. , . .
8. , . .
9. , . , , , .
10. , ѐ , , . ѐ .
11. , ( ) , , Shell-. :
12. , (,.tmp) , , Shell-. Shell- , :
13. , , Shell-. , , .