douglasg@hpgrla.HP.COM (@Douglas Genetten) (07/17/88)
Is there a filter which converts tabs to n-spaces throughout a file? Thanks.
grs@alobar.ATT.COM (Gregg Siegfried) (07/19/88)
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. Enjoy, Gregg Siegfried att!alobar!grs grs@alobar.att.com
leo@philmds.UUCP (Leo de Wit) (07/19/88)
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.
sow@eru.mt.luth.se (Sven-Ove Westberg) (07/21/88)
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? | |Thanks. What about this???!!!! EXPAND(1) UNIX Programmer's Manual EXPAND(1) NAME expand, unexpand - expand tabs to spaces, and vice versa SYNOPSIS expand [ -tabstop ] [ -tab1,tab2,...,tabn ] [ file ... ] unexpand [ -a ] [ file ... ] Sven-Ove Westberg, CAD, University of Lulea, S-951 87 Lulea, Sweden. UUCP: {uunet,mcvax}!enea!cad.luth.se!sow ARPA: sow%cad.luth.se@ucbvax.berkeley.edu (only dumb ARPA mailers) Internet: sow@cad.luth.se Bitnet: sow%cad.luth.se@sekth
dmt@ptsfa.PacBell.COM (Dave Turner) (07/21/88)
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? You might try newform and/or sed. newform will convert tabs into the correct number of spaces so that the output will appear to have been printed on a printer with tab stops. If your input file assumes that tabs are to appear to have been set every eight spaces try: newform -i-8 -o-0 < inputfile If you want each tab to be converted into a fixed number of spaces use sed: sed -n -e "s/ / /p" < inputfile If you want each tab converted into exactly one space tr will also work. -- Dave Turner 415/542-1299 {att,bellcore,sun,ames,pyramid}!pacbell!dmt
rick@vsi1.UUCP (Rick Schneider) (07/21/88)
From article <3940001@hpgrla.HP.COM>, by douglasg@hpgrla.HP.COM (@Douglas Genetten): > Is there a filter which converts tabs to n-spaces throughout > a file? > Try the translate filter: tr '\11' '\40' < input_file > output_file this will map a tab to one space (a \11 is the tab character and the \40 is the space character) -- Rick Schneider ...pyramid!vsi1!rick VICOM SYSTEMS, INC.; 2520 Junction Avenue, San Jose, Ca, 95134, (408) 432-8660 The opinions expressed are not those of my employer or are they?
jbush@ficc.UUCP (james bush) (07/21/88)
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? | | Thanks. try pr with the -t and the -e options (See the manual for the exact format). eg. pr -t -e converts tabs to spaces for 8 characters. -- James Bush, Ferranti, Houston The Bible - the "source code" of life Internal address: jbush extension 5230, mail stop A/3204, room A/3602 External address: ..!uunet!nuchat!sugar!ficc!jbush
jon@jonlab.UUCP (Jon H. LaBadie) (07/23/88)
I'm unfamiliar with expand/unexpand. BSD, comp.unix.sources? What I have used, at least on System V boxes, is the "newform" command, for example: newform -i6,20,35 file_name for columns at 0, 6, 20, and 35. Tabs in the file, spaces on standard out. Is this inappropriate or somehow showing my age? -- Jon LaBadie {att, ulysses, princeton}!jonlab!jon
robert@pvab.UUCP (Robert Claeson) (07/25/88)
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? The pr(1) command under UNIX System V has an option -e (for 'expand') that will replace tabs with the appropriate amount of spaces.
dawson@fpssun.fps.com (Bryan Dawson ext 1184) (07/25/88)
In article <4425@ptsfa.PacBell.COM>, dmt@ptsfa.PacBell.COM (Dave Turner) 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? > > You might try newform and/or sed. Several replies have mentioned tr or sed. I assume that the desired result is to convert tabs to spaces *in a fomat preserving manner*. The correct standard tool to do this in UNIX is expand. Expand is designed to perform exactly this function (and its inverse 'unexpand') and does so very well.
dmt@ptsfa.PacBell.COM (Dave Turner) (07/26/88)
In article <453@jonlab.UUCP> jon@jonlab.UUCP (Jon H. LaBadie) writes: > > newform -i6,20,35 file_name > >for columns at 0, 6, 20, and 35. Tabs in the file, spaces >on standard out. The command as shown will output tabs because an output tabspec was omitted. For an input file with tabs that are assumed to be set in columns 6, 20 and 35 with spaces in the output the newform command should be: newform -i6,20,35 -o-0 file_name The -o-0 argument says to output tabs that are assumed to be set every zero characters. The default is -o-8 (tabs assumed to be set every eight characters). -- Dave Turner 415/542-1299 {att,bellcore,sun,ames,pyramid}!pacbell!dmt
leo@philmds.UUCP (Leo de Wit) (07/26/88)
In article <453@jonlab.UUCP> jon@jonlab.UUCP (Jon H. LaBadie) writes: |I'm unfamiliar with expand/unexpand. BSD, comp.unix.sources? BSD. |What I have used, at least on System V boxes, |is the "newform" command, for example: | | newform -i6,20,35 file_name | |for columns at 0, 6, 20, and 35. Tabs in the file, spaces |on standard out. Expand works about the same (minor difference). Unexpand works the other way around. B.T.W. I find both names - expand & newform - not very descriptive. |Is this inappropriate or somehow showing my age? Neither. Unless in the sense of: true wizdom comes with age 8-). |-- |Jon LaBadie |{att, ulysses, princeton}!jonlab!jon Leo.
ask@cbnews.ATT.COM (Arthur S. Kamlet) (08/03/88)
>> >Is there a filter which converts tabs to n-spaces throughout >> >a file? >> You might try newform and/or sed. >Several replies have mentioned tr or sed. I assume that the desired >result is to convert tabs to spaces *in a fomat preserving manner*. >The correct standard tool to do this in UNIX is expand. Expand is >designed to perform exactly this function (and its inverse 'unexpand') >and does so very well. On our UNIX V system, col -x works pretty well. col -x < oldfile > newfile or: cat oldfile | col -x > newfile seems to work rather quickly and simply. -- Art Kamlet ask@cbrmb.att.com AT&T Bell Laboratories, Columbus