列印與圖案匹配的線條(PCRE grep)

perl -ne'print if /foo/' file.txt

不區分大小寫:

perl -ne'print if /foo/i' file.txt