2013-10-14 01:19:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
2013-10-03 09:18:01 +00:00
|
|
|
|
|
|
|
DEPTH=5
|
|
|
|
COUNT=10000
|
|
|
|
|
2013-10-14 01:19:03 +00:00
|
|
|
kill_jobs() {
|
2013-10-03 09:18:01 +00:00
|
|
|
jobs -p | xargs kill
|
|
|
|
}
|
2013-10-14 01:19:03 +00:00
|
|
|
trap kill_jobs INT
|
2013-10-03 09:18:01 +00:00
|
|
|
|
2013-10-14 01:19:03 +00:00
|
|
|
create_files() {
|
2013-10-03 09:18:01 +00:00
|
|
|
for i in `seq 1 $COUNT`
|
|
|
|
do
|
|
|
|
touch file$i
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-10-14 01:19:03 +00:00
|
|
|
delete_files() {
|
2013-10-03 09:18:01 +00:00
|
|
|
for i in `ls -f`
|
|
|
|
do
|
|
|
|
if [[ ${i}a = file*a ]]
|
|
|
|
then
|
|
|
|
rm -f $i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
rm -rf testdir
|
|
|
|
mkdir testdir
|
|
|
|
cd testdir
|
|
|
|
|
|
|
|
for i in `seq 1 $DEPTH`; do
|
|
|
|
mkdir dir$i
|
|
|
|
cd dir$i
|
|
|
|
create_files &
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
|
|
|
|
for i in `seq 1 $DEPTH`; do
|
|
|
|
delete_files &
|
|
|
|
cd ..
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
rm -rf testdir
|