已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题吗?**通过editing this post添加详细信息并阐明问题。
去年关闭了。
Improve this question
在Linux中,我有一个类似于下面的文件test.log:
2021/11/18 17:19:18,034 INFO {"queueName":"queue/RequestQueue",{"threadName":"WorkManager(2)-702","correlationID":"b67601e81bfd","requestData":"TYPE_1, REQUEST 1"}
2021/11/18 17:19:18,036 INFO {"queueName":"queue/ResponseQueue","correlationID":"TMYHxIyeYo","responseData":"TYPE_1, RESPONSE 1"}
2021/11/18 17:19:18,038 INFO {"queueName":"queue/RequestQueue",{"threadName":"WorkManager(2)-885","correlationID":"j9BNzbbv3E","requestData":"TYPE_2, REQUEST 2"}
2021/11/18 17:19:19,172 INFO {"queueName":"queue/RequestQueue",{"threadName":"WorkManager(2)-183","correlationID":"d29d2d7cf5a4","requestData":"TYPE_1, REQUEST 3"}
2021/11/18 17:19:20,784 INFO {"queueName":"queue/esbRequestQueue",{"threadName":"WorkManager(2)-762","correlationID":"4235eba2765a","requestData":"TYPE_1, REQUEST 4"}
我想搜索这个文件的所有行,找到包含字符串[“requestData”:“TYPE_1]的行,并将requestData的所有内容写入另一个名为type_1.txt的文件中。test.log文件中的每一个匹配行都将被写入type_1.txt文件中的一行。下面是我在type_1.txt文件中的预期结果:
TYPE_1, REQUEST 1
TYPE_1, REQUEST 3
TYPE_1, REQUEST 4
我的问题是有没有可以做到这一点的命令?我是Linux新手,所以请帮助我。
1条答案
按热度按时间jk9hmnmh1#
请尝试以下命令: