我有几个关键词的文本文件。我必须从这些文件中选择几行并解析它。以下是一个示例文件。我必须grep“客户”,并从文件中获取该行。使用shell脚本解析文本
13 Sun Sep 9 12:14:38 2012 : [P] Reproducer has the 167 number
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.14.19.9
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.14.89.9
13 Sun Sep 9 12:14:38 2012 : [P] Reproducer has the 170 number
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.4.89.16
我只有选择具有客户的线条和必须分析它仅获得时间戳(十二时14分38秒)和数字12.14.19.9。我必须为多个文件执行此操作。所有文件都具有相同的日志结构。我已经做了这样的使用下面的线索
grep Customer Neigh.log | cut -d " " -f 5- | cut -d ":" -f 1-4 | cut -d " " -f 1,8
但我需要在一个shell脚本内做到这一点。我怎样才能做到这一点。谁能帮忙?
感谢
看起来你已经*写过你的脚本。问:你需要做什么,你还没有做?你已经拥有了什么?你还需要什么? – paulsm4
它工作正常..但我需要给文件名作为参数在shell脚本和实现相同的功能..我没有使用shell脚本。所以只是想知道如何在shell脚本中做到这一点.. – user1667228