Here is a little bash Unix utility to see the top and bottom of a file (as I like to do) in Unix. It is (almost) my first Unix utility. Enjoy!!!
#!/usr/bin/env bash
if (( $# != 1 ))
then
echo ‘This utility shows the head and tail of a file ‘
echo ‘usage: ‘
echo ‘peek <-n number of lines> list of files ‘
echo ”
echo ‘if -n option is not provided the default of 6 is used’
echo ”
echo ‘Developed by Mario Segal – free to use and modify as you wish’
else
num=6
while getopts n:: flag;
do
case $flag in
n) num=$OPTARG
esac
done
shift $((OPTIND-1))
for file in “$@”
do
echo file: “$file”
echo ‘head’
echo ‘—————————-‘
head -n $num $file
echo ‘—————————-‘
echo ‘tail’;
echo ‘—————————-‘
tail -n $num $file
echo ‘—————————-‘
echo ”
done
fi
: <<END_IF_DOCS
=head1
This utility will show both the head and the tail for a file, or a list fo files
=head1 OPTIONS
-n <number of lines to show on head and tail, default if the head/tail default of 6>
=head1 LICENSE AND COPYRIGHT
Developed by Mario Segal – use it at will
=cut
END_IF_DOCS