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