text: user3766: I have multiple files (n=86000) with one column each and I want to combine them all into one file with 86000 columns.
  I tried the following command
  Paste *.txt > mean.txt
  
  And as a for loop
  for i in *.txt, do paste $i > mean.txt; done 
  
  This did not appear to work because there are 86000 to combine, I then divided my files into multiple folders with each folder not containing more than 15000 files but this did not working
  Format of my single file is as follows (It has 16000 lines)
  0.047202943506056
  0.0383549703366668
  0.0159162908608477
  0.0238048058550539
  0.0694728928685859
  0.0389052658410832
  
  What is the bug in the code?
  
  user3848: The bug in your loop appears be "> filename" per column, this over-rides the last iteration resulting in a file with a single column, which has been over-written 85999 times. Thus the file output you observe should be the single column present in the last file of your array. If you replaced "> filename" with ">> filename" within the loop you would then append to the file a new column with each iteration. If the loop fell over at some point you could then simply use one of the outputs of wc filename to assess how many columns you had (you might have to transponse the data for wc to work (lots of scripts for this in Perl), although there will almost certainly be an easy solution for counting columns in awk. 
  Personally, I would use a dataframe for this operation (possibly R, definately Python pandas), because 86000 columns is a lot of columns in any other walk of life, even if it is just post-processing. Generally, if you just want bash, awk is a better solution in this case (I don't code with it, but some here certainly do). However, I do get the idea that paste will work if each column is an identical length.
  BTW paste must be lower case, you've got Paste in the first line of your code, but its okay in the second bit of code.
  BTW BTW, I did not know shell would take *.txt directly as an array, with Perl/Python you need to "glob" it and assign it as an array/list.
  
original_text: 3766: <p>I have multiple files (n=86000) with one column each and I want to combine them all into one file with 86000 columns.</p>
  <p>I tried the following command</p>
  <pre><code>Paste *.txt &gt; mean.txt
  </code></pre>
  <p>And as a for loop</p>
  <pre><code>for i in *.txt, do paste $i &gt; mean.txt; done 
  </code></pre>
  <p>This did not appear to work because there are 86000 to combine, I then divided my files into multiple folders with each folder not containing more than 15000 files but this did not working</p>
  <p>Format of my single file is as follows (It has 16000 lines)</p>
  <pre><code>0.047202943506056
  0.0383549703366668
  0.0159162908608477
  0.0238048058550539
  0.0694728928685859
  0.0389052658410832
  </code></pre>
  <p>What is the bug in the code?</p>
   3848: <p>The bug in your loop appears be "<code>&gt; filename</code>" per column, this over-rides the last iteration resulting in a file with a single column, which has been over-written 85999 times. Thus the file output you observe should be the single column present in the last file of your array. If you replaced "<code>&gt; filename</code>" with "<code>&gt;&gt; filename</code>" within the loop you would then append to the file a new column with each iteration. If the loop fell over at some point you could then simply use one of the outputs of <code>wc filename</code> to assess how many columns you had (you might have to transponse the data for wc to work (lots of scripts for this in Perl), although there will almost certainly be an easy solution for counting columns in awk. </p>
  
  <p>Personally, I would use a dataframe for this operation (possibly R, definately Python pandas), because 86000 columns is a lot of columns in any other walk of life, even if it is just post-processing. Generally, if you just want bash, awk is a better solution in this case (I don't code with it, but some here certainly do). However, I do get the idea that <code>paste</code> will work if each column is an identical length.</p>
  
  <p>BTW <code>paste</code> must be lower case, you've got <code>Paste</code> in the first line of your code, but its okay in the second bit of code.</p>
  
  <p>BTW BTW, I did not know shell would take *.txt directly as an array, with Perl/Python you need to "glob" it and assign it as an array/list.</p>
  