Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建与数据一起运行的 bash 脚本的日志文件。我目前有这个:
bash script.sh > /var/log/%Y-%m-%d_%H:%M.log
问题是日志文件实际写入 %Y-%m-%d_%H:%M 而不是日期。有没有办法通过仅在控制台中运行来获取实际写出日期的日期?
将该字符串传递给date:
date
bash script.sh > "/var/log/$(date +%Y-%m-%d_%H:%M).log"