Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  Downloads
    Scripts
      Korn
        K93_Unix

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com



#!/usr/bin/ksh93
################################################################
#### Program: colrm_k93
#### 
#### Description: Emulation of the Unix "colrm" colrmand
#### 
#### Author: Dana French (dfrench@mtxia.com)
####         Copyright 2004
#### 
#### Date: 07/22/2004
#### 
################################################################
# FPATH="."
function colrm_k93 {
  typeset TRUE="0"
  typeset FALSE="1"

  if [[ "_${1}" = '_-?' ]]
  then
    print -u 2 "Syntax: colrm_k93 [-f] [startcol [endcol]]"
    print -u 2 "        -f remove fields instead of columns"
    return 4
  fi

  typeset RMFIELD="${FALSE}"
  if [[ "_${1}" = '_-f' ]]
  then
    RMFIELD="${TRUE}"
    shift
  fi

  typeset STARTCOL="${1}"
  typeset ENDCOL="${2}"

  if (( RMFIELD == FALSE ))
  then
    while read -r -- COLS
    do
      print -r -n -- "${COLS:0:STARTCOL-1}"
      print -r -- "${ENDCOL:+${COLS:ENDCOL}}"
    done
  fi

  if (( RMFIELD == TRUE ))
  then
    while read -A -r -- COLS
    do
      ENDCOL="${2:-${#COLS[*]}}"
      for (( i = ( STARTCOL - 1 ); i <= ( ENDCOL - 1 ); ++i ))
      do
        unset COLS[${i}]
      done
      for COL in "${COLS[@]}"
      do
        print -r -n -- "${COL}	"
      done
      print
      unset COLS
    done
  fi
  return ${?}
}
################################################################

colrm_k93 "${@}"

-
colrm_k93
-
 


FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com