1 / 16

OS haldamine

OS haldamine. Allan Liblik. Tingimuslikud tegevused. if (tingimuse käsk) then käsk 1 käsk 2 ..... käsk n fi. Kui tingimus ei ole täidetud. if (tingimuse käsk) then käsk 1 käsk 2 ..... käsk n else käsk 1 käsk 2 ..... käsk n fi. if elif else.

Download Presentation

OS haldamine

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OS haldamine Allan Liblik

  2. Tingimuslikud tegevused if (tingimuse käsk)then käsk 1 käsk 2 ..... käsk n fi

  3. Kui tingimus ei ole täidetud .. if (tingimuse käsk)then käsk 1 käsk 2 ..... käsk n else käsk 1 käsk 2 ..... käsk n fi

  4. if elif else if (tingimuse käsk)then käsk 1 ..... käsk n elif(tingimuse käsk2)then käsk 1 ..... käsk n else käsk 1 ..... käsk n fi

  5. programmide kontroll • sh -c exit • which ssh • Teha skript, mis otsib shellide sh csh bash tsh olemasolu masinas. • Tulemus ntx selline: sh olemas. csh olemas. bash olemas. tsh pole

  6. Kokkuvõttev süntaks if list; then list; [ elif list; then list; ] ... [ elselist; ] fi

  7. true ja false true – tagastab alati exit-koodi 0 (viga ei ole) false – tagastab alati exit-koodi 1 (viga on) true echo $? false echo $?

  8. sh shelli olemasolu kontroll if (sh -c exit) then echo "sh on olemas ... " else echo "sh nimelist shelli ei ole olemas ... " fi erinevad shellid: sh bash ksh csh tcsh zsh

  9. test, [ -d fileTrue if file exists and is a directory. -e file True if file exists (regardless of type). -f fileTrue if file exists and is a regular file. -h fileTrue if file exists and is a symbolic link. -r fileTrue if file exists and is readable. -s fileTrue if file exists and has a size greater than zero. -w fileTrue if file exists and is writable. True indicates onlythat the write flag is on. The file is not writable on aread-only file system even if this test indicates true. -x fileTrue if file exists and is executable. True indicates onlythat the execute flag ison. If file is a directory, true indicates that file can be searched.

  10. test - stringid -n string True if the length of string is nonzero. -z string True if the length of string is zero. s1 = s2 True if the strings s1 and s2 are identical. s1 != s2 True if the strings s1 and s2 are not identical. s1 < s2 True if string s1 comes before s2 based on the ASCII value of their characters. s1 > s2 True if string s1 comes after s2 based on the ASCII value of their characters. s1 True if s1 is not the null string.

  11. test - algebra n1 -eq n2True if the integers n1 and n2 are algebraically equal. n1 -ne n2True if the integers n1 and n2 are not algebraically equal. n1 -gt n2True if the integer n1 is algebraically greater than the integer n2. n1 -ge n2True if the integer n1 is algebraically greater than orequal to the integer n2. n1 -lt n2True if the integer n1 is algebraically less than the integer n2. n1 -le n2True if the integer n1 is algebraically less than or equalto the integer n2.

  12. algebra näide if [ $# -eq 0 ]; then echo "$0 : Pead ette andma yhe arvu!" exit 1 fi if (test $1 -gt 0) then echo "arv $1 on positiivne" else echo "arv $1 on negatiivne" fi *ülesanne - nulli kohta öelda et on null.

  13. "imelikud" muutujad shelli built-in muutujad $# argumentide koguarv $* kõik argumendid $0 käsk ise $1 esimene argument $n n'is argument $? viimase käsu exit-kood

  14. Imelike muutujate kasutamine echo '*' $* echo '#' $# echo '0' $0 echo '1' $1 echo '$' $$ skript a b fff 678 wwee

  15. Matemaatilised tehted expr 1 + 3 expr 2 - 1 expr 10 / 2 expr 20 % 3 expr 10 \* 3 expr1 {=, >, >=, <, <=, !=} expr2 - võrdemised

  16. Ülesanne • Kontrollib kas parameetrina etteantud fail on olemas ja kas see on kirjutatav, loetav ja pikkus 0 baidist suurem. • Kontrollib kas kaks etteantud stringi on ühesugused. • Nimetab faile ümber nii et faili nime etteantud algus asendatakse teise etteantud algusega.

More Related