-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools_example_file_prepare.sh
45 lines (37 loc) · 1.03 KB
/
tools_example_file_prepare.sh
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
export TOOLS_FILE="$(dirname "$0")/tools.sh"
source "$TOOLS_FILE" "$@" || { echo "Error: Can't load \"$TOOLS_FILE\" file!" && exit 1; }
FILE_TEST="TestFile"
function testfiles
{
case "$1" in
prepare)
rm -f "$FILE_TEST"*
echo "o" > "$FILE_TEST"
for I in 1 2 3 4 5 6 7 8 9 10 11
do
echo "$I" > "$FILE_TEST-$I"
done
;;
show)
# file_loop "TestFile*" << 'EOF'
#echo -e " $FILE\\t$(cat $FILE)"
#EOF
file_loop "$FILE_TEST*" 'echo -e " $FILE\t\t$(cat $FILE)\t$(stat -c %s "$FILE")b"'
;;
delete)
rm -f "$FILE_TEST"*
;;
esac
}
print info "Rolling old files example"
testfiles prepare
print step "Files before prepare"
testfiles show
# roll file if is bigger than 1b
file_prepare --size 1 "$FILE_TEST"
# roll files, default old files count = 9
file_prepare --roll "$FILE_TEST"
print step "Files after prepare"
testfiles show
testfiles delete