Last active
September 3, 2023 08:28
-
-
Save kou1okada/80e6ba1960f173db45cab79377b621b3 to your computer and use it in GitHub Desktop.
ddrescueutils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/gawk -f | |
BEGIN { | |
bad_sector = non_split = non_trimmed = finished = non_tried = 0; | |
} | |
$3 == "-" {bad_sector += strtonum($2);} | |
$3 == "/" {non_split += strtonum($2);} | |
$3 == "*" {non_trimmed += strtonum($2);} | |
$3 == "+" {finished += strtonum($2);} | |
$3 == "?" {non_tried += strtonum($2);} | |
END { | |
info("?", non_tried); | |
info("+", finished); | |
info("-", bad_sector); | |
info("/", non_split); | |
info("*", non_trimmed); | |
info("-/*", bad_sector + non_split + non_trimmed); | |
} | |
function info(stat, size) { | |
printf("%-3s: %17s bytes (%13s blocks)\n", stat, numsep(size), numsep(size / 512)); | |
} | |
function numsep(v, _h, _l) { | |
if (3 < length(v)) { | |
_l = substr(v, length(v) - 2, 3); | |
_h = substr(v, 0, length(v) - 3); | |
return numsep(_h) "," _l; | |
} else { | |
return v; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/gawk -f | |
/^#/ | |
!/^#/ { | |
for (i = 1; i <= NF; i++) { | |
if (match($i, /^0x/)) { | |
$i = sprintf("%'18d", strtonum($i)); | |
} | |
} | |
print $0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/gawk -f | |
BEGIN { | |
W = 64; // width of map | |
addr = 0; | |
s = ""; | |
} | |
NF == 3 { | |
n = strtonum($2) / 512; | |
for (i = 0; i < n; i++) { | |
s = s $3; | |
if (W <= length(s)) { | |
printf("%08x %s\n", addr, s); | |
s = ""; | |
addr += W; | |
# skip continuous lines | |
continuous = int((n - i) / W); | |
if (0 < continuous) { | |
printf("<skip %d lines %s>\n", continuous, $3); | |
addr += continuous * W; | |
i += continuous * W; | |
} | |
} | |
} | |
} | |
END { | |
printf("%08x %s\n", addr, s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment