×
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>mutante
    mNo edit summary
    imported>DrOwl
    (added if else)
    Line 14: Line 14:
    # gzip $x
    # gzip $x
    done
    done






    Line 25: Line 27:




    ==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





    Revision as of 11:24, 9 July 2008

    Template loop detected: Template:Stub

    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
    



    Simple while loop (infanitly repating)

    while :
    do
    tail log.file
    sleep 23
    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
    
    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.