#!/bin/bash
# 用法: ./scan_pages.sh /usr/local/mysql/data/db3/gms_id_data.ibd

FILE=$1
PAGES=$(( $(stat -c%s "$FILE") / 16384 ))

echo "文件大小: $(stat -c%s "$FILE") 字节"
echo "总页数: $PAGES"

for i in $(seq 0 $((PAGES-1))); do
    # 从每一页里提取可见字符串，查找关键字
    STRINGS=$(./page_parser -4 -f "$FILE" -p $i | strings | egrep "AGMS|GMS|machineID" | head -3)
    if [ ! -z "$STRINGS" ]; then
        echo "=== Page $i 可能有业务数据 ==="
        echo "$STRINGS"
        echo
    fi
done

