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.
我正在学习shell脚本。
我需要将每个新条目或新行捕获到日志文件中,然后将该行复制到另一个文件中。
示例:我想将 /var/log/maillog 中的每个新条目复制到 //newlog.log
问候,
tail -0f /var/log/maillog | tee -a ../newlog.log
0in是不复制现有的-0f尾条目,并且只开始尾尾新条目。tee用于将标准输出重定向到另一个位置。-a正如人们所指出的那样,该选项用于附加到输出文件而不是覆盖它。
0
-0f
tee
-a