【问题标题】:shell script connect three commandsshell脚本连接三个命令
【发布时间】:2014-08-23 10:35:17
【问题描述】:

我有 shell 脚本,需要将某个目录中的文件和文件夹数量转发到 .txt 文件,我用 ls |厕所 -

但在该文件中需要是脚本运行的日期和时间

ls |厕所-l |日期 > prep.txt

在文件准备中,我只有日期而不是文件和文件夹的第一个计数

【问题讨论】:

    标签: shell date time terminal ls


    【解决方案1】:

    date 不读取其标准输入;管它是没有意义的。

    date >prep.txt
    ls | wc -l >>prep.txt
    

    如果你坚持单次重定向,

    { date; ls | wc -l; } >prep.txt
    

    你也可能变得非常复杂;

    date +"%c $(ls | wc -l)" >prep.txt
    

    但真的没有理由去那里。

    【讨论】:

      猜你喜欢
      • 2021-05-10
      • 1970-01-01
      • 2014-12-13
      • 2016-12-20
      • 2020-11-30
      • 2016-11-28
      • 1970-01-01
      • 1970-01-01
      • 2021-12-11
      相关资源
      最近更新 更多