]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/bin/rm-stale-test-logs
ld64-409.12.tar.gz
[apple/ld64.git] / unit-tests / bin / rm-stale-test-logs
CommitLineData
a61fdf0a
A
1#!/bin/sh
2
3usage() {
4 echo Usage: $0 number-of-tests-logs-to-keep
5 echo where number-of-tests-logs-to-keep must be a non-zero integer
6 exit
7}
8
9# Usage: if no arguments
10[ -z "$1" ] && usage
11
12# Check if requesting 0 tests to remain!
13[ "$1" -ne 0 ]
14
15# don't test directly--use the result value
16# because the command can fail for badly formed integers
17[ $? -ne 0 ] && usage
18
19# get the dir names of all tests in date order
20ls -1dtr /tmp/proctor*>/tmp/all$$ 2>/dev/null
21
22# select the last few to keep
23tail -$1 /tmp/all$$>/tmp/keep$$
24
25# get a list of the others
26DELLIST=`diff /tmp/all$$ /tmp/keep$$|grep '^<'|sed -e 's/^< //'`
27
28# any work to do?
29if [ "$DELLIST" ]
30then
31 echo rm -rf $DELLIST
32 rm -rf $DELLIST
33fi
34
35# rm the temps
36rm /tmp/all$$ /tmp/keep$$