×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Korn shell: Difference between revisions

    Content added Content deleted
    imported>DrOwl
    (added if else)
    imported>DrOwl
    (cleaned up a ltl)
     
    Line 1: Line 1:
    {{stub}}
    {{stub}}
    KSH is a [[Unix]] shell, it has scripting cabilities


    =Scripts=
    ==Korn Shell==

    KSH is a [[Unix]] shell, it has scripting cabilities


    Here are some example of basic scripting commands


    === Examples for loops in ksh ===
    == loops ==


    Simple for loop
    ===Simple for loop===


    for x in `ls .tar$` ; do
    for x in `ls .tar$` ; do
    Line 18: Line 18:




    Simple while loop (infanitly repating)
    ===Simple while loop (infanitly repating)===
    while :
    while :
    do
    do

    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
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.