如何用换行符替换回车符后如何将终端中的dd进程重定向到日志文件

问题描述 投票:0回答:2

知道为什么该命令不起作用?

dd if=/dev/zero of=/dev/null status=progress |& tr '\r' '\n' >> test.txt

我希望test.txt的内容看起来像这样。

395191296 bytes (395 MB, 377 MiB) copied, 1 s, 395 MB/s
805187584 bytes (805 MB, 768 MiB) copied, 2 s, 403 MB/s
1239563264 bytes (1.2 GB, 1.2 GiB) copied, 3 s, 413 MB/s
1666015232 bytes (1.7 GB, 1.6 GiB) copied, 4 s, 417 MB/s

现在命令不打印任何内容到test.txt

bash shell command-line stdout dd
2个回答
0
投票

使用tee例如:

dd if=/dev/zero of=/dev/null status=progress 2>&1 | tee test

然后您可以将\ r替换为\ n或用nano打开>


0
投票

全部是因为tr等待其工作完成,这将花费无限的时间。

© www.soinside.com 2019 - 2024. All rights reserved.