From owner-freebsd-questions@FreeBSD.ORG Sat May 21 05:13:01 2011 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 8C8C6106564A for ; Sat, 21 May 2011 05:13:01 +0000 (UTC) (envelope-from perryh@pluto.rain.com) Received: from agora.rdrop.com (agora.rdrop.com [IPv6:2607:f678:1010::34]) by mx1.freebsd.org (Postfix) with ESMTP id 1482E8FC0C for ; Sat, 21 May 2011 05:13:00 +0000 (UTC) Received: from agora.rdrop.com (66@localhost [127.0.0.1]) by agora.rdrop.com (8.13.1/8.12.7) with ESMTP id p4L5ClSH074503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 20 May 2011 22:12:49 -0700 (PDT) (envelope-from perryh@pluto.rain.com) Received: (from uucp@localhost) by agora.rdrop.com (8.13.1/8.12.9/Submit) with UUCP id p4L5Cllg074502; Fri, 20 May 2011 22:12:47 -0700 (PDT) Received: from fbsd61 by pluto.rain.com (4.1/SMI-4.1-pluto-M2060407) id AA03343; Fri, 20 May 11 22:01:34 PDT Date: Fri, 20 May 2011 22:00:39 -0700 From: perryh@pluto.rain.com To: kline@thought.org Message-Id: <4dd746f7.Yuut6+YR+YWLNlCn%perryh@pluto.rain.com> References: <20110518191001.GA22364@thought.org> <201105201412.p4KECZUO078750@fire.js.berklix.net> <20110520232536.GA5016@thought.org> In-Reply-To: <20110520232536.GA5016@thought.org> User-Agent: nail 11.25 7/29/05 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: jhs@berklix.com, dnelson@allantgroup.com, freebsd-questions@freebsd.org Subject: Re: Expanding tabs (was Re: kwik way?) 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: Sat, 21 May 2011 05:13:01 -0000 Gary Kline wrote: > how to i get, say > hello, \t how are \t you > to translate to > hello, how are you > [?] > in other words, tab -> 1 space rather than the defaul of 4. You only need something like "expand" or "tab.c" if you want to convert each tab to a variable number of spaces depending on column position. If you just want each tab to become a single space, which is what I think your "in other words" says: $ tr '\011' ' ' < input > output If you want each _sequence of one or more tabs and/or spaces_ to become a single space, which is what the example looks like: $ sed 's/[ ^I][ ^I]*/ /g' < input > output (^I represents an actual tab character; in bash I get that by the two-keystroke sequence CtrlV CtrlI but other shells may vary. Dunno offhand if sed would understand the \t or \011 notation.)