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
Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.