-1

我正在开发一个 shell 脚本,它执行一个返回校验和字符串的命令。这个字符串的每个十六进制都用空格分隔,我想删除一些东西,例如,4AA512,而不是 4A A5 12 作为命令输出,但我找不到有效的解决方案。这里的脚本:

for /f  "delims=" %%f in ('dir %~dp0*.zip /b') do (
    echo %%~f:
    for /f "delims=" %%a in ('certUtil -hashfile "%~dp0%%~f" SHA512 ^| find /i /v "SHA512" ^| find /i /v "certUtil"^') do (
          echo %%a:' '=''%
        )

    set /a counter += 1
    echo.
 )

有人有解决方案吗?

谢谢!

4

1 回答 1

1

(答案从问题/评论转移到 - 嗯 - 一个答案)

终于找到了解决办法:

set counter=0
for /f  "delims=" %%f in ('dir %~dp0*.zip /b') do (
    echo %%~f:
    for /f "delims=" %%a in ('certUtil -hashfile "%~dp0%%~f" SHA512 ^| find /i /v "SHA512" ^| find /i /v "certUtil"^') do (call :ShowChecksum "%%a")
    set /a counter += 1
    echo.
)

echo %counter% files(s) found.
pause
exit

:ShowChecksum
set "checksum=%~1"
set "checksum=%checksum: =%"
echo %checksum%
于 2018-10-17T14:40:33.710 回答