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.
我正在尝试编写一个脚本,该脚本可以在日志文件中搜索特定文本并在 txt 文件中写下该行。日志文件每 2 天存档一次,因此我还需要在存档文件中进行搜索。
就像是:
-bash-3.2$ ssh server.com -bash-3.2$ cd test/log/ less server.log.2012-06-19.gz | grep "text" -> ~/test.txt
我是 UNIX 的新手 谢谢
像这样?
zgrep text server.log* >~/test.txt
gzcat <your_gz_file>|grep string >output_file