From bc90aad16e0f2918c7c551152de0bf876ab52a3c Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 24 Jul 2024 13:58:17 +0200 Subject: script for replacing timestamp in logs for easy testing of -c --- test/test_replace_timestamp.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 test/test_replace_timestamp.sh (limited to 'test/test_replace_timestamp.sh') diff --git a/test/test_replace_timestamp.sh b/test/test_replace_timestamp.sh new file mode 100755 index 0000000..ffad66e --- /dev/null +++ b/test/test_replace_timestamp.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +LOG_DIR="/home/oskar/.trashsys/log" + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +REPLACEMENT="$1" + +if [ ! -d "$LOG_DIR" ]; then + echo "Directory $LOG_DIR does not exist." + exit 1 +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" + fi +done + +echo "Done." -- cgit v1.2.3