January 2004
Intermediate to advanced
368 pages
7h 25m
English
Many of the most common Unix commands have evolved within slow-throughput, expensive output environments and therefore offer minimal output and interactivity. An example is cat: When used to view a short file, it really doesn't have much helpful output. It would be nice to have more information about the file. This script, a more sophisticated variation of Script #31, accomplishes this.
#!/bin/sh # showfile - Shows the contents of a file, including additional useful info. width=72 for input do lines="$(wc -l < $input | sed 's/ //g')" chars="$(wc -c < $input | sed 's/ //g')" owner="$(ls -ld $input | awk '{print $3}')" echo "-----------------------------------------------------------------" ...Read now
Unlock full access