file format....

I have a file of 1000 rows , I need to format it to be coulmn seperatred by TAB , and print it

Ex:

12345
12345
12343
32232
23432
34242
43224

to like

12345 TAB 12345
12343 TAB 32232
23432 TAB 34242
43224 TAB .........

Thanks alot for your helping and care...

paste - - < inputfile

default output delimiter is a tab....

cheers
ZB

Can be processed using sed...????

Thanks,,
Atiato

Code :-

sed 's/^\([0-9]*\)/\1 \1/' inputfile

sed "$!N;s/\n/$(/bin/echo '\t')/" inputFile

Vgresh ,

Can u plz explain that ...

Could you explain your sed script, please ?

Thanks,
vino

sed "$!N;s/\n/$(/bin/echo '\t')/" inputFile

from 'man sed'

N                Append the next line of input to
                 the pattern space with an embed-
                 ded new-line.  (The current line
                 number  changes.)   If  no  next
                 line of input is available,  the
                 N  command  verb shall branch to
                 the end of the script  and  quit
                 without starting a new cycle and
                 without  writing   the   pattern
                 space.

!command     |  Don't.  Apply  the  command  (or|
             |  group,  if command is {) only to|
             |  lines  not   selected   by   the|
             |  address(es).                    | 

$                 Last line

Having said that.....

'$!N' translates into except for the last line append the Next line to the pattern space with the embedded newline.

Having the 'embedded new line' in the pattern space, next command [s/\\n/$\(/bin/echo '\\t'\)] substitutes new line '\n' with a TAB character. The tab character is produced by active function using 'echo' - '$(/bin/echo .....)'.

the following error has occured while using Sed command:

root@Billtest # sed "$!N;s/\n/$(/bin/echo '\t')/" om
sed: command garbled: N;s/\n/$(/bin/echo '\t')/

Please Advise!!!

Works fine on Solaris with stock 'sed' under ksh.