From 847b56294b70ed7bbef0fcf2fb25ef878581568c Mon Sep 17 00:00:00 2001 From: Oskar <> Date: Sun, 3 Nov 2024 15:39:31 +0100 Subject: functions to remove all trashed files, and to remove old trashed files. Not fully tested. Also modified a script that replaces timestamps --- test/test_generate_delete.sh | 2 +- test/test_replace_timestamp.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_generate_delete.sh b/test/test_generate_delete.sh index 6764682..810eb96 100755 --- a/test/test_generate_delete.sh +++ b/test/test_generate_delete.sh @@ -1,6 +1,6 @@ #!/bin/bash -for i in {1..10} +for i in {1..5} do ./gentestfiles.sh ./test_deletefiles.sh diff --git a/test/test_replace_timestamp.sh b/test/test_replace_timestamp.sh index ffad66e..a8f44b9 100755 --- a/test/test_replace_timestamp.sh +++ b/test/test_replace_timestamp.sh @@ -3,7 +3,7 @@ LOG_DIR="/home/oskar/.trashsys/log" if [ -z "$1" ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi @@ -16,8 +16,12 @@ fi for file in "$LOG_DIR"/*; do if [ -f "$file" ]; then - echo "replacing trashed time in: $file" - awk -v replacement="$REPLACEMENT" 'NR % 5 == 0 {print replacement} NR % 5 != 0 {print $0}' "$file" > "$file.tmp" && mv "$file.tmp" "$file" + echo "Replacing timestamp in: $file" + awk -v replacement="$REPLACEMENT" '{ + # Replace the fifth field (timestamp) with the replacement string + $5 = replacement + print $0 + }' "$file" > "$file.tmp" && mv "$file.tmp" "$file" fi done -- cgit v1.2.3