Tag: bash

bash is the gnu project’s shell, the bourne again shell. an sh-compatible shell that incorporates useful features from the korn shell (ksh) and the c shell (csh), and offers functional improvements over sh for both programming and interactive use.

  • until … done loop in gnu/bash

    bash has three types of loop constructs
    – for
    – while
    – until

    until loop is used to iterate over the body of the loop till the condition stays false.

    syntax:

    until [ condition ];
    do
    block-of-statements
    done

    example:

    #!/bin/bash
    echo “example of until”
    i=20
    until [ $i == 1 ]; do  # condition stays false
      echo "${i} is still greater than 1”
      i=$((i-1))  # i = i - 1
    done
    echo “value of i = ${i}"

    You may chose to throw this code in a shell script and see it go.

  • unexport/remove a variable in the shell

    say you have assigned some value to a variable from the shell or a shell script using the export command and now you want to remove that variable, either programatically or manually.

    (more…)