Sunday, June 7, 2009

Search for a range of lines


# Use awk's range operator, a comma, to print an entire
# function definition in an init script

awk '/action\(\) {/ , /}/' /etc/init.d/functions

    action() {
      local STRING rc

      STRING=$1
      echo -n "$STRING "
      shift
      "$@" && success $"$STRING" || failure $"$STRING"
      rc=$?
      echo
      return $rc
    }

No comments:

Post a Comment