【问题标题】:How to print the file slowly?如何打印文件慢?
【发布时间】:2021-06-11 13:39:44
【问题描述】:

我正在准备一个演示文稿,我希望在我评论它的同时将一个文件立即打印在屏幕上。输入cat file.txt | less 似乎是一个显而易见的解决方案,但还有其他更优雅、更赏心悦目的解决方案吗?

【问题讨论】:

    标签: linux shell file unix cat


    【解决方案1】:
    perl -ne '$|=1; for (split //) { print; select(undef,undef,undef, 0.15) }' file.txt
    

    $|=1 不缓冲。

    for (split //) { print; ...对于每个打印的字符...

    select(undef,undef,undef, 0.15)sleep 0.15 秒(你可以根据自己的口味和需要改变这个值)。

    【讨论】:

      猜你喜欢
      • 2014-03-17
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多