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 usageif (($# < 1))thenprint "Usage: $0 file ..."exit 1fi# Process each filewhile (($# > 0))do# Make sure file existsif [[ ! -f $1 ]]thenprint "$1: non-existent or not accessible"else# Open file for inputexec 0<$1while read LINEdo# Display outputprint $LINEdonefi# Get next file argumentshiftdone