[英]How to remove carriage return and line feed characters from a text file using batch?
[英]How to remove CRLF and a new line from text file using batch command
目标是使用批处理脚本执行以下操作:
我系统的主机名是: W0000000000ZQ
我的批处理脚本如下所示:
@echo off
hostname>hostname.txt
CertUtil -hashfile hostname.txt SHA256 //<- this is generating wrong sha256 string because
// the above generated file contains CRLF and a new line
// screenshot of this file provided below.
CertUtil -hashfile hostname-manual.txt SHA256 //<- this is generating correct sha256 string because
// i manually created this file and pasted hostname
// only (W0000000000ZQ) without CRLF and new line.
// screenshot of this file provided below.
主机名.txt:
主机名手册.txt
脚本的输出:
您能否建议如何从“hostname.txt”中删除 CRLF 和换行符,以便 Certutil 选择正确的字符串来生成 sha256 值。
下面将主机名保存到一个没有尾随 CRLF 的文件中。
for /f %%h in ('hostname') do (>hostname.txt <nul set /p unused=%%h)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.