我有一个 files students.txt
,具有以下形式的行:
Surname, Forename: Day.Month.Year: Degree
Run Code Online (Sandbox Code Playgroud)
例如:
Smith, John: 15.01.1986: MSc IT
Taylor, Susan: 04.05.1987: MSc IT
Thomas, Steve: 19.04.1986: MSc MIT
Sellen, Jo: 03.07.1987: MSc CSE
Run Code Online (Sandbox Code Playgroud)
如何将下面的sed
命令更改为返回所有1987年出生的学生的姓氏的命令?
$ grep 1987 students.txt | grep -o "^\(.*\),"
Run Code Online (Sandbox Code Playgroud)