Text Processing – Extract Lines from Files with Specific Name Patterns

regular expressionsedtext processing

Got here a list of columns, as follows:

59  LOUIS   1202    +1
60  FREDDIE 1201    +4
61  FINLAY  1200    -2
62  LEON    1137    +12
63  HARLEY  1132    +6
64  DAVID   1127    -1
65  MOHAMMAD1100    +6
66  REECE   1095    -1
67  KIAN    1090    0
68  KAI     1056    -6
69  KYLE    1030    -18
70  BRANDON 1011    -4
71  HAYDEN  1006    +5
72  ZACHARY 995     +10
73  KIERAN  973     -12
73  LUCA    973     -1
75  ASHTON  954     +4
76  BAILEY  939     -6
77  JAKE    913     +10
78  GABRIEL 910     +14
79  SAM     900     -2
80  EVAN    890     0
81  BRADLEY 847     -13

How could be extracted only the lines with, for example, letter "L", as follows:

73  LUCA    973     -1

Best Answer

That seems to be duplicated, but anyway, if it was understood, one may do it as follows:

First, save the list in a some nameslist.txt file, then:

sed -rn '/^[^\s]+\s+[F]/p' list.txt > result.txt, which should return following output in result.txt file:

60 FREDDIE 1201 +4 61 FINLAY 1200 -2

Related Question