From owner-freebsd-questions@FreeBSD.ORG Tue Sep 25 03:07:22 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72D4C16A419 for ; Tue, 25 Sep 2007 03:07:22 +0000 (UTC) (envelope-from hg@queue.to) Received: from pickle.queue.to (pickle.queue.to [71.180.69.18]) by mx1.freebsd.org (Postfix) with ESMTP id E943913C457 for ; Tue, 25 Sep 2007 03:07:21 +0000 (UTC) (envelope-from hg@queue.to) Received: (qmail 53261 invoked from network); 24 Sep 2007 23:07:20 -0400 Received: from cally.queue.to (172.16.0.6) by pickle.queue.to with ESMTP; 24 Sep 2007 23:07:20 -0400 Message-ID: <46F87B68.6090607@queue.to> Date: Mon, 24 Sep 2007 23:07:20 -0400 From: Howard Goldstein User-Agent: Thunderbird 2.0.0.6 (X11/20070802) MIME-Version: 1.0 To: Gary Kline References: <20070925013723.GA50027@thought.org> In-Reply-To: <20070925013723.GA50027@thought.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: sed question... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2007 03:07:22 -0000 Gary Kline wrote: > My earlier post about deleting the first N lines was answered by > this one-liner site {below}. I wasn't including any > redirection; doing so finally resolved the problem. Now I need > to delete every line from the 19th or so to the last line. > Question one, can anybody explain the following syntax? What do > "P", "D" "ba" represent, in other words? > > > # delete the last 10 lines of a file > sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1 > sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2 > > > Question two, can sed do its thing inline? Wouldn't it be easier to use head -n 18 ?