Content added Content deleted
imported>DrOwl (New page: ==Korn Shell== KSH is a unix shell, it has scripting cabilities === Examples for loops in ksh === Simple for loop for x in `ls .tar$` ; do echo "gzip $x" # gzip $x done Sim...) |
imported>DrOwl (cleaned up a ltl) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1:
{{stub}}
KSH is a [[Unix]] shell, it has scripting cabilities
=Scripts=
== loops ==
===
for x in `ls .tar$` ; do
Line 15 ⟶ 16:
Simple while loop (infanitly repating)▼
▲===Simple while loop (infanitly repating)===
while :
do
Line 22 ⟶ 25:
clear
done
==If Else==
===Noarmal way===
if [ -f /usr/bin/sudo ] ; then
SUDO='/usr/bin/sudo'
else
SUDO=''
fi
echo $SUDO
===Sneeky way===
[ -f /usr/bin/sudo ] && SUDO='/usr/bin/sudo' || SUDO='' ; echo $SUDO
[[Category:Programming]]
[[Category:Linux]]
[[Category:Hacking]]
[[Category:Computer]]
[[Category:Unix]]
|
Latest revision as of 11:28, 9 July 2008
Template loop detected: Template:Stub KSH is a Unix shell, it has scripting cabilities
Scripts[edit]
Here are some example of basic scripting commands
loops[edit]
Simple for loop[edit]
for x in `ls .tar$` ; do echo "gzip $x" # gzip $x done
Simple while loop (infanitly repating)[edit]
while : do tail log.file sleep 23 clear done
If Else[edit]
Noarmal way[edit]
if [ -f /usr/bin/sudo ] ; then SUDO='/usr/bin/sudo' else SUDO= fi echo $SUDO
Sneeky way[edit]
[ -f /usr/bin/sudo ] && SUDO='/usr/bin/sudo' || SUDO= ; echo $SUDO