-2

I have a list of objects in column (file_column.txt) and I want to transpose this objects in row using "," as delimiter in a new file (file_row.txt).

Es.

file_column.txt:
Art
14f
adr
a24

file_row.txt: Art,14f,adr,a24

I try to use this code:

paste -s -d " " tabella.txt

but the result it isn't right because I obtained this:

Art
,14f
,adr
,a24

Can you help me please?

2 Answers2

4

You have to use the right delimiter (comma) with the -d parameter:

cat file
Art
14f
adr
a24
paste -sd, file
Art,14f,adr,a24
thanasisp
  • 8,122
0
#! /bin/bash

while read line
 do
  string="${string},${line}"
 done < file_column.txt

echo ${string#","} > file_row.txt


This works.

The while read construction is more portable as it uses only Bash syntax and the builtin read.

Asker321
  • 139