我需要从包含特定字段的文件中获取记录。示例:
Mozart 于1756年1月27日出生于1756年,出生于利奥波德莫扎特(1719-1787)和安娜玛丽亚(N Pertl )(1720-1778),出生于格特列迪格斯9号。
我只需要得到Mozart和1756 (出生于1月27日)之间的田野。
发布于 2014-06-14 07:29:25
这个awk可以做到:
awk -F"Mozart | 1756" '{print $2}' file
was born on 27 January如果你喜欢的话:
grep -oP 'Mozart .*? 1756' file
Mozart was born on 27 January 1756发布于 2014-06-14 06:55:37
因为你特别要求awk
echo "Mozart was born on 27 January 1756 to Leopold Mozart (1719–1787) and Anna Maria, née Pertl (1720–1778), at 9 Getreidegasse" | awk ' match($0, /Mozart(.*)1756/) { print substr($0,RSTART+6,RLENGTH-10) }'版画
was born on 27 January https://stackoverflow.com/questions/24217347
复制相似问题