Expanding tabs (was Re: kwik way?)
perryh at pluto.rain.com
perryh at pluto.rain.com
Sat May 21 05:13:01 UTC 2011
Gary Kline <kline at 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.)
More information about the freebsd-questions
mailing list