January 2001
Intermediate to advanced
480 pages
7h 22m
English
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
Read now
Unlock full access