Systemy operacyjne - lab. 12 ==================================================== 1- powtorka if [ $? -eq 0 ] if [ $# -le 2 ] less than two args if [ "$1" = "tekst" ] "$1" to avoid error if $1 not defined if [ -f "$1" -a -r "$1" ] "$1" to avoid error if $1 not defined zmienne specjalne n arg 0 nazwa skryptu # liczba args @ lista args "$1" .. "$n" * lista args "$1 .. $n" ? last stat $ PID this shell ! PID last proc in backg 2- petle for f in *.txt do mv $f $f.TXT done `seq 3 7` while [ -n "$1" ] do echo "$1" shift done true while ! ping -c 1 sirius > /dev/null 2>&1 -c stops after 1 send do sleep 20 done echo "siec OK" | mail .. break ends loop continue przejscie do kolejnej iteracji 3- case case $x in v) .. ;; v1|v2) .. ;; esac case $x in [tT]*) .. ;; *) .. ;; esac 4- inne read while read l do echo $l done < plik cat plik | dwa procesy => l not seen outside loop while read l do echo $l done grep .. | head .. | while 5- functions procesy () { local x=1 ps -u $1 } procesy user unset proc 6- lista args lista.txt: a1 a2 c2 grep ^a lista.txt | xargs -t chmod go-x -t echoes executed command (option) chmod go-x a1 a2 grep ^a lista.txt | xargs -n 1 -t chmod go-x chmod go-x a1 chmod go-x a2 (option -n specifies max number of args) jak wprowadzic args w srodku ? see below sh -c 'echo $2 $1' skrypt a b -c wykonanie komend podanych w linii grep ^a lista.txt | xargs sh -c 'cp $* /tmp' skrypt cp a1 a2 /tmp