Transpose column into row based on the new line

Viewed 120

I have file like this

d
e
e

s
k

a
b
c
d

I just need to convert then as like this

dee
sk
abcd

For this purpose I used awk and xargs

xargs < file|awk '{ gsub (" ", "", $0); print}'

But it is not generating results as expected

4 Answers
$ awk -v RS= -v OFS='' '{$1=$1}1' file

dee
sk
abcd

Could you please try following.

awk '
!NF && value{
  print value
  value=""
  next
}
NF{
  value=value $0
}
END{
  if(value){
     print value
  }
}' Input_file

Using :

perl -0pe 's/\n(?=.)//g' file

Output

dee
sk
abcd
perl -l -00pe 'y/\n//d' file

-00 is similar to awk -v RS=

Related