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


Mt Xia:
Technical Consulting Group

 

ls_k93


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

Current:ls_k93
Previous:
Home Page



#!/usr/bin/ksh93
################################################################
function usagemsg_ls_k93 {
  print -- "
Program: ls_k93

The ls_k93 function writes to standard output a message containing the 
system identifications (ID) for a specified user.  The system IDs 
are numbers which identify users and user groups to the system.

Usage: ${1##*/} [-vV] [-1adlrF] [FILE]...

    Where:
      -v = Verbose mode
      -V = Very Verbose mode

Author: Dana French (dfrench@mtxia.com)    Copyright 2004

\"AutoContent\" enabled"
  return 0
}
################################################################
#### 
#### Description:
#### 
#### The ls_k93 function writes to standard output a message
#### containing the system identifications (ID) for a
#### specified user.  The system IDs are numbers which
#### identify users and user groups to the system. 
#### 
#### Assumptions:
#### 
#### Dependencies:
#### 
#### Products:
#### 
#### Configured Usage:
#### 
#### Details:
#### 
################################################################
function ls_k93 {
  typeset TRUE="0"
  typeset FALSE="1"
  typeset VERBOSE="${FALSE}"
  typeset VERYVERB="${FALSE}"
  typeset DOTFILES="${FALSE}"
  typeset FILETAG="${FALSE}"
  typeset REVERSE="${FALSE}"
  typeset DIREXPAND="${TRUE}"
  typeset LONGLIST="${FALSE}"
  typeset LONGLINE=""
  typeset SCRWID="80"
  typeset IIDX IPOS ILEN
  typeset JIDX JPOS JLEN
  typeset TAG

  while getopts ":1adlrF" OPTION
  do
    case "${OPTION}" in
        '1') SCRWID="0";;
        'a') DOTFILES="${TRUE}";;
        'd') DIREXPAND="${FALSE}";;
        'l') LONGLIST="${TRUE}";;
        'F') FILETAG="${TRUE}";;
        'r') REVERSE="${TRUE}";;
        'v') VERBOSE="${TRUE}";;
        'V') VERYVERB="${TRUE}";;
        '?') usagemsg_ls_k93 "${0}" && return 1 ;;
    esac
  done
 
  shift $(( ${OPTIND} - 1 ))

################################################################

#### 
#### If a list of files and/or directories were specified on the
#### command, assign this list of files and dirs to an array,
#### one array element per file/directory.
#### If no files or directories were specified on the command
#### line, and the '-a' option was specified, gather a list
#### of all files in the current directory including the
#### 'dot' files.  If the -a option was not specified, then
#### don't include the 'dot' files.
#### 

  IFS=""
  (( ${#} != 0 )) && FILELIST=( "${@}" )
  (( ${#} == 0 )) && (( DOTFILES == TRUE  )) &&  FILELIST=( . .. .[!.]* * )
  (( ${#} == 0 )) && (( DOTFILES == FALSE )) &&  FILELIST=( * )
  IFS=$' \t\n'

#### 
#### If there were no 'dot' files in the current directory,
#### the third array position may contain a literal
#### representation of the korn shell pattern used to attempt
#### to gather the 'dot' files.  If so reset this array
#### position to NULL.  Also determine the number of
#### elements in the array for use in an arithmetic for loop.
#### 

  [[ "_${FILELIST[2]##*/}" = '_.[!.]*' ]] && FILELIST[2]=""
  ILEN="${#FILELIST[*]}"

#### Loop through each array position to display each file in
#### the list.  Begin at array element 0 and continue through
#### to the last array position.

  for (( IIDX=0; IIDX /dev/null 2>&1
          then
              print -u 2 "ls_k93: ${FILE}: Permission denied"
              continue
          fi

#### Generate a list of files in the new directory and save
#### this list to a new array.

          unset DIRLIST
          IFS=""
          (( DOTFILES == TRUE )) &&
              DIRLIST=( . .. .[!.]* * ) ||
              DIRLIST=( * )


#### 
#### If there were no 'dot' files in the new directory,
#### the third array position may contain a literal
#### representation of the korn shell pattern used to attempt
#### to gather the 'dot' files.  If so reset this array
#### position to NULL.  Also determine the number of
#### elements in the array for use in an arithmetic for loop.
#### 

          [[ "_${DIRLIST[2]##*/}" = '_.[!.]*' ]] && DIRLIST[2]=""
          JLEN="${#DIRLIST[*]}"

#### Loop through each array position to display each file in
#### the list.  Begin at array element 0 and continue through
#### to the last array position.

          for (( JIDX=0; JIDX

 

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