Date: Fri, 20 May 2011 22:00:39 -0700 From: perryh@pluto.rain.com To: kline@thought.org Cc: jhs@berklix.com, dnelson@allantgroup.com, freebsd-questions@freebsd.org Subject: Re: Expanding tabs (was Re: kwik way?) Message-ID: <4dd746f7.Yuut6%2BYR%2BYWLNlCn%perryh@pluto.rain.com> In-Reply-To: <20110520232536.GA5016@thought.org> References: <20110518191001.GA22364@thought.org> <201105201412.p4KECZUO078750@fire.js.berklix.net> <20110520232536.GA5016@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Gary Kline <kline@thought.org> 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.)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4dd746f7.Yuut6%2BYR%2BYWLNlCn%perryh>