Path: utzoo!attcan!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions Subject: Re: tabs converted to spaces? Keywords: sed, expand Message-ID: <566@philmds.UUCP> Date: 19 Jul 88 15:54:04 GMT References: <3940001@hpgrla.HP.COM> <187@alobar.ATT.COM> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 26 In article <187@alobar.ATT.COM> grs@alobar.att.com (Gregg Siegfried) writes: >In article <3940001@hpgrla.HP.COM> douglasg@hpgrla.HP.COM (@Douglas Genetten) writes: >>Is there a filter which converts tabs to n-spaces throughout >>a file? > >I've found that tr(1) does a pretty good job of this. If you're printing >the file, pr(1) also does what you need. Tr translates characters, and will thus generally not do what Douglas wants it to: n-spaces. All you could do with tr is translate each tab into a (1) space (unless you know something about tr that I do not). Pr does too much, unless indeed all you want to do is format the file. Two alternatives: if you want the filter to know of tabstops (thus expanding into spaces until the next tabstop) use expand (and to reverse: unexpand); you can even use your favourite tabstop sequence. If you just want to replace each tab by a certain constant number of spaces, you could use sed: sed 's/ / /g' your_tab_file >your_space_file ^ ^^^^ TAB your n spaces. Enjoy! Leo.