I have two files that I am trying to merge, one file is:linux$ cat temp2linear_0_A_B linear_0_B_A103027.244444 102714.177778103464.311111 102876.266667103687.422222 103072.711111103533.244444 102967.733333103545.066667 102916.933333103621.555556 103027.511111104255.776536 103006.256983103712.178771 102877.139665103817.555556 103198.488889103701.422222 103133.200000And the other file is:linux$ cat templinear_1_A_B linear_1_B_A118620.444444 109212.355556108408.488889 105744.444444108136.311111 105174.933333108627.688889 105390.044444108356.577778 105412.888889108559.204420 105667.933702108469.392265 105547.314917109032.044693 105497.698324108925.866667 105986.222222107975.733333 105070.000000I want to paste the columns in temp into temp2, and retain the temp2 file like this:linux$ paste temp2 templinear_0_A_B linear_0_B_A       linear_1_A_B linear_1_B_A103027.244444 102714.177778     118620.444444 109212.355556103464.311111 102876.266667     108408.488889 105744.444444103687.422222 103072.711111     108136.311111 105174.933333103533.244444 102967.733333     108627.688889 105390.044444103545.066667 102916.933333     108356.577778 105412.888889103621.555556 103027.511111     108559.204420 105667.933702104255.776536 103006.256983     108469.392265 105547.314917103712.178771 102877.139665     109032.044693 105497.698324103817.555556 103198.488889     108925.866667 105986.222222103701.422222 103133.200000     107975.733333 105070.000000But when I do standard output, and display temp2, the result is not the same. linux$ paste temp2 temp > temp2linux$ cat temp2        linear_1_A_B linear_1_B_A        118620.444444 109212.355556        108408.488889 105744.444444        108136.311111 105174.933333        108627.688889 105390.044444        108356.577778 105412.888889        108559.204420 105667.933702        108469.392265 105547.314917        109032.044693 105497.698324        108925.866667 105986.222222        107975.733333 105070.000000How to resolve??
Problem with paste and standard output in linux
text processing;io redirection;paste
You wrote in your last block,linux$ paste temp2 temp > temp2You cannot do this. (Well you can, but it won't work.) What happens here is that the shell truncates temp2 ready to send output from the paste command. The paste temp2 temp command then runs - but by this stage temp2 is already zero length.What you can do instead is this, which uses a third file to collect the output and then replaces your temp2 with its content. The && ensures that the content is only replaced if the paste succeeded, and the rm -f removes the transient temp3 file if the mv wasn't triggered, or failed in some unexpected way.paste temp2 temp > temp3 && mv -f temp3 temp2rm -f temp3