1
vote
2answers
48 views

Is there a way to print 2 lines (if any) before and after a target or print a placeholder if not?

I'm not native english speaker so I hope to be clear. I know about grep -C 2 "TARGET" inputfile to select 2 rows before and after the row of the TARGET, but I'm not able to use it to manage my ...
0
votes
2answers
448 views

Using sed, how to print all lines that match a certain date?

Using sed, how to print all lines where the birthdays are in November or December? Assuming input file name "datebook" as follows: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
2
votes
2answers
782 views

How to egrep the first character in second column?

Using egrep, how can I print all lines where last names start with K or k? Jennifer Cowan:548-834-2348:583 Laurel Ave., Kingsville, TX 83745:10/1/35:58900 Lesley Kirstin:408-456-1234:4 Harvard ...
1
vote
3answers
655 views

How to grep only selected words from a file?

I need to get a list of all the email addresses from a file. I was trying to use grep @ filename but that returns the entire line. Is there anyway I can get it to return only the email address ...