From owner-freebsd-questions@FreeBSD.ORG Tue Feb 27 12:20:02 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 997AD16A400 for ; Tue, 27 Feb 2007 12:20:02 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from gaia.nimnet.asn.au (nimbin.lnk.telstra.net [139.130.45.143]) by mx1.freebsd.org (Postfix) with ESMTP id 354E313C428 for ; Tue, 27 Feb 2007 12:20:00 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (smithi@localhost) by gaia.nimnet.asn.au (8.8.8/8.8.8R1.5) with SMTP id XAA08969; Tue, 27 Feb 2007 23:19:51 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Tue, 27 Feb 2007 23:19:51 +1100 (EST) From: Ian Smith To: Kelly Jones In-Reply-To: <20070227074143.8840716A411@hub.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-questions@freebsd.org Subject: Re: Effectively detaching 'less' from a pipe 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, 27 Feb 2007 12:20:02 -0000 In freebsd-questions Digest, Vol 167, Issue 5 At Message: 19 On Mon, 26 Feb 2007 20:27:41 -0700, Kelly Jones wrote: > I often run commands piped to 'less', to make sure the command is > working OK by looking at the first few lines of output. > > Once I'm convinced, though, I'd like to "get rid" of less, and just > have the rest of stdout spewed to the terminal (and/or /dev/null > and/or to a file I specify). > > In other words, I want to stop hitting 'space' until my program terminates. What Matthew said about using 'F' to follow output tail is very handy. > How can I do this? > > My current kludges (both ugly): > > 1. do "command > file" and then "tail -f file | less" (this mostly > works, but takes a while to get started because of buffering issues) > > 2. do "command | less", and once I'm happy w/ the output, hit 'q' to > quit less (and thus terminate program) and then do "command > > /dev/null" (works, but wastes time, since I have to run the command > once just to look at the first few lines and then abort it) When you've piped something to less that you want to save, or save some part of, press 'g' to go to top of file (or position the top of what you want to save at top of screen), press 'm' and some letter (I mostly use 'mm' for speed) to mark that spot, press 'G' to go to bottom of file (or otherwise position the end of what you want at bottom of screen), then press '|' then (as prompted for) the letter of your mark (eg here '|m') Then at the '!' command prompt offered, type 'cat - >somepath/filename' to capture the file, or snippet. If you use >> instead of > you can cat interesting sections of your output to a file; using up/down arrow at '!' you can recall commands used, for each mark/move/pipe/cat sequence. Cheers, Ian