Files
openclaw-ops/scripts/safe-jsonl-peek.sh

29 lines
449 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <jsonl-file> [max-bytes-per-file]" >&2
exit 1
fi
FILE="$1"
MAX_BYTES="${2:-1048576}"
if [[ ! -f "$FILE" ]]; then
echo "error: file not found: $FILE" >&2
exit 1
fi
SIZE=$(wc -c < "$FILE")
if [[ "$SIZE" -le "$MAX_BYTES" ]]; then
cat "$FILE"
exit 0
fi
HALF=$(( MAX_BYTES / 2 ))
head -c "$HALF" "$FILE"
printf '\n...TRUNCATED...\n'
tail -c "$HALF" "$FILE"