我有一个很大的文本列表,为了更容易地进行排序,我希望能够将具有特定单词的行导出到另一个文本文件中。
以下是案文的一个例子:
- JOCKEY: D Tudhope riding Dynamic Force in the 1.45 at Ayr
- TRAINER: A W Carroll training Be Fair in the 1.55 at Lingfield Park
- TRAINER: M L W Bell training The Vegas Raider in the 1.55 at Lingfield Park
- JOCKEY: Oisin Murphy riding The Vegas Raider in the 1.55 at Lingfield Park
- JOCKEY: W Buick riding Crestwood in the 1.55 at Lingfield Park
- TRAINER: P F Nicholls training Chez Hans in the 2.05 at Newton Abbot
- JOCKEY: Callum Rodriguez riding Gigiʼs Beach in the 2.15 at Ayr我怎样才能只将写着“玲菲尔德公园”的行导出到另一个文本文件中?
我希望这是合理的。
发布于 2021-07-25 19:44:30
一个简单的grep +重定向:
$ grep '\bLingfield Park\b' FILE > ANOTHER_FILE
$ cat ANOTHER_FILE
- TRAINER: A W Carroll training Be Fair in the 1.55 at Lingfield Park
- TRAINER: M L W Bell training The Vegas Raider in the 1.55 at Lingfield Park
- JOCKEY: Oisin Murphy riding The Vegas Raider in the 1.55 at Lingfield Park
- JOCKEY: W Buick riding Crestwood in the 1.55 at Lingfield Parkhttps://unix.stackexchange.com/questions/659893
复制相似问题