1#!/bin/sh
2#
3# $OpenBSD: reverse-chars.sh,v 1.1 2015/11/24 04:04:19 tedu Exp $
4
5# test if tail grep the correct number of blocks from a file.
6
7DIR=$(mktemp -d)
8echo DIR=${DIR}
9
10NAME=${0##*/}
11OUT=${DIR}/${NAME%%.sh}.out
12i=0
13while [ ${i} -lt 512 ]; do
14	echo ${i} >> ${DIR}/bar
15	i=$((i+1))
16done
17
18tail -c 50 ${DIR}/bar > ${OUT}
19tail -c -50 ${DIR}/bar > ${OUT}1
20
21diff -u ${OUT} ${OUT}1 || exit 1
22diff -u ${OUT} ${0%%.sh}.out || exit 1
23
24# cleanup if okay
25rm -Rf ${DIR}
26