Display Files - kcat

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Appendix D.  Sample Korn Shell Scripts


Display Files - kcat

Here is a simple Korn shell version of the Unix cat command. It is only 3-4 times slower than the Unix version (on a 100-line file), because it uses the exec command for the file I/O.

 #!/bin/ksh  #  #     kcat - Korn shell version of cat  #  # Check usage  if (($# < 1))  then        print "Usage: $0 file ..."        exit 1  fi  # Process each file  while (($# > 0))  do        # Make sure file exists        if [[ ! -f $1 ]]        then              print "$1: non-existent or not accessible"        else              # Open file for input              exec 0<$1              while read LINE              do                    # Display output                    print $LINE              done        fi        # Get next file argument        shift  done 

       
    Top
     



    Korn Shell. Unix and Linux Programming Manual, Third Edition
    Korn Shell. Unix and Linux Programming Manual, Third Edition
    ISBN: N/A
    EAN: N/A
    Year: 2000
    Pages: 177

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net