0

I have a large list of text and, to make it easier to sort through, I would like to be able to export lines that feature certain words to another text file.

Here is an example of the text:

- 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

How can I export only the lines that say "Lingfield Park" to another text file?

I hope this makes sense.

5

A simple grep + redirection:

$ 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 Park
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.