Initial commit: OpenClaw ops workspace
This commit is contained in:
28
scripts/safe-jsonl-peek.sh
Executable file
28
scripts/safe-jsonl-peek.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user