Hi guys,
So I have a file containing data of a marathon. Here's an example what it looks like including the given key:
# key: sex, time, athlete, athlete's nationality, date, city, country
M, 2:30:57.6, Harry Payne, GBR, 1929-07-05, Stamford Bridge, England
M, 2:5:42, Khalid Khannouchi, MAR, 1999-10-24, Chicago, USA
M, 2:5:37.8, Khalid Khannouchi, USA, 2002-04-14, London, USA
My task is to extract all lines that feature a runner's last name starting with a C.
What I did was; I sorted the file according to key 4 and redirected the output to a new file, which gave me the list sorted in alphabetical order according to their last name. I used this command to do this;
sort -k 4 marathon > t21a
.
Does anyone know if there is a command that allows me to grep all entries which have the last name starting with C from the key position these terms are in?
Any help would be much appreciated.
I have tried to grep from a key position but the option I used(from sort) does not exist for grep;
grep -k 4 '^[C,c]' t21b > t21c
Thank you