100% Spam Free Email | Contact Us | Products/Services | Korn Shell | MicroEMACS


Mt Xia:
Technical Consulting Group

 

awk_k93


Contact Mt Xia for help with your shell scripting projects at 615.556.0456 or dfrench@mtxia.com

Current:awk_k93
Previous:
Home Page



#!/usr/bin/ksh93
################################################################
#### Program: awk_k93
#### 
#### Description: This is a korn shell emulation of the "awk" 
#### capability of extracting and reordering fields from an 
#### input stream.
#### 
#### Author: Dana French (dfrench@mtxia.com)
####         Copyright 2004
#### 
#### Date: 07/22/2004
#### 
#### Syntax: awk_k93 [-FX] '{ print $# ... }' < file
#### 
#### Where -FX allows the field delimiter to be defined as the
####   character X.
#### 
####   One or more fields can be returned based on the positional
####   parameters defined in the required parameter.  The "print"
####   statement is required to simulate the "awk" syntax.
#### 
################################################################
function awk_k93 {
  [[ "_${1:?${0}: undefined parameter}" = _-F? ]] && IFS="${1#-F}" && shift
  VARS="${1// /}"
  VARS="${VARS/#\{print(*)\}/print -r -- \1}"
  while read LINE
  do  eval set -- ${LINE}
      eval eval "\"${VARS//,/ }\""
  done
} 
################################################################

awk_k93 "${@}"

 

For information regarding this page, contact Dana French ( dfrench@mtxia.com )
Copyright 2008 by Mt Xia Inc, All Rights Reserved