#awk '/B/{print a;}{a=$0}' a.txt A # cat a.txt A BCDE 转载于:https://www.cnblogs.com/Berryxiong/p/6209351.html