Export list of numbers as one line to a text file

I have the following list:

list = {1,2,3,4,5}


Now I would like to export the list to a text file such that the numbers are all on one line separated by a tab:

1 2 3 4 5

When I do:

Export["list.txt",list]


I get:

1

2

3

4

5

I am wondering if it is possible to get the desired output ?

• Export["list.txt", list, "Table", "LineSeparators" -> " "]? – Sjoerd Smit Sep 25 '19 at 9:26
• @Sjoerd Smit Yes, that's exactly what I was looking for. Thanks a lot. You can post it as an answer, then I can accept it. :) – henry Sep 25 '19 at 9:31

The following should work:

Export["list.txt", list, "Table", "LineSeparators" -> " "]


The "Table" format also supports a "FieldSeparators" option to separate columns in 2D data, should you need it.

My take on it:

list = {{1, 2, 3, 4, 5}}

Export["list.txt", list, "TSV"]


In TSV values in the same row are delimited by tab and values in the same column are delimited by newline.