# Function to get latest checkpoint MD5 by journal number
get_latest_checkpoint_md5() {
local checkpoint_dir="$1"
local latest_md5=""
local max_journal=0
# Use glob with nullglob to handle no matches gracefully
shopt -s nullglob
for md5_file in "${checkpoint_dir}"/checkpoint*.md5; do
# Extract journal number from filename
if [[ $(basename "$md5_file") =~ checkpoint\.ckp\.([0-9]+)\.md5$ ]]; then
journal_num="${BASH_REMATCH[1]}"
# Remove leading zeros for numeric comparison
journal_num=$((10#$journal_num))
if (( journal_num > max_journal )); then
max_journal=$journal_num
latest_md5="$md5_file"
fi
fi
done
shopt -u nullglob
echo "$latest_md5"
}
# Sample Usage:
# LatestCheckpointMD5=$(get_latest_checkpoint_md5 "${ShowCheckpoints[i]}")
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 32236 | C. Thomas Tyler |
Released SDP 2025.2.32234 (2025/12/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| //guest/perforce_software/sdp/dev/Server/Unix/p4/common/lib/latest_checkpoint.lib | |||||
| #2 | 32205 | C. Thomas Tyler | tweaked. | ||
| #1 | 32204 | C. Thomas Tyler | Aded function to get latest checkpoint MD5 file. | ||