Korn shell

From S23Wiki

KSH is a Unix shell, it has scripting cabilities

Contents

[edit] Scripts

Here are some example of basic scripting commands

[edit] loops

[edit] Simple for loop

for x in  `ls .tar$` ; do  
echo "gzip $x"
# gzip $x
done



[edit] Simple while loop (infanitly repating)

while :
do
tail log.file
sleep 23
clear
done


[edit] If Else

[edit] Noarmal way

if [ -f /usr/bin/sudo ] ; then
        SUDO='/usr/bin/sudo'
else
        SUDO=
fi
echo $SUDO

[edit] Sneeky way

[ -f /usr/bin/sudo ] && SUDO='/usr/bin/sudo' || SUDO= ; echo $SUDO
Personal tools