我正在尝试为脚本设置 cron 作业,该脚本将在某个目录中附加当前日期/时间和文件数。我只能对文件数量执行此操作:
ls | wc -l >> /root/log.txt
Run Code Online (Sandbox Code Playgroud)
但是如何在此条目中包含日期/时间?
qua*_*nta 16
$ echo "$(date) $(ls -1 | wc -l)" >> /root/log.txt
Run Code Online (Sandbox Code Playgroud)