Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Lines to Column conversion

$
0
0
Hi All,

I have a sample file with content:
Code:

[root@xyx1 tmp]# cat test1.txt
mahesh
suresh
anil
[root@xyx1 tmp]#

I need to get it like this:
Code:

m s a
a u n
h r i
e e l
s s
h h

Basically row to column and column to row. I am trying to use this:
Code:

while read line
do
    echo $line | fold -bw 1
done<test1.txt

But its showing output as
Code:

m
a
h
e
s
h
s
u
r
e
s
h
a
n
i
l

Can anyone help please?

Thanks,
RK


Moderator's Comments:
Please use code tags next time for your code and data.

Viewing all articles
Browse latest Browse all 16232

Trending Articles