Category: Shell

shell scripting and the tools that live in the terminal: bash, awk, vim.

  • 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…)
  • awk tricks

    some of the awk tricks listed here. might come in handy in any of my future shell scripts.

    (more…)
  • my .vimrc file

    everybody has their own distinct style of using the editor of their choice. when i am using vim, i prefer to have the following defined in the .vimrc file in the root directory of my user on gnu linux/mac os.

    use .vimrc to save your vi settings if you prefer using the plain old vi instead.

    (more…)