blob: a8f44b98d2664011990dd7396878d0d48f2137a9 (
plain)
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
|
#!/bin/bash
LOG_DIR="/home/oskar/.trashsys/log"
if [ -z "$1" ]; then
echo "Usage: $0 <replacement_timestamp>"
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 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
echo "Done."
|