-2

I just would like to combine different txt files into one file using shell script;

The first text file has the values;

2.3444 5.66666

The second has the values;

4.5556 2.44444

I want combine them so that the final text file must be in the following format;

2.3444 5.66666
4.5556 2.44444

I tried the following scripts but it didn't work;

paste -d, all1.txt all1.25.txt > Results1.txt


awk 'NR==FNR {h[$2] = $3; next} {print $1,$2,h[$2]}' all1.txt all1.25.txt > file3.txt

closed as unclear what you're asking by Michael Homer, Jeff Schaller, Thor, Rui F Ribeiro, roaima Jun 9 '17 at 10:46

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Is the command you are looking for cat? – Michael Homer Jun 9 '17 at 8:39
  • 4
    You should provide enough input and output to tell what's going on, or explicitly say that you want alternating lines. – Jeff Schaller Jun 9 '17 at 9:19
2

You need to specify delimeter for paste "\n"

paste -d "\n" 1.txt 2.txt 3.txt 4.txt > Results.txt
  • Many thanks for the reply and help. The command works perfect for two txt files. However, If I had 3 or more txt file for instance, I got the following; 1.39928 12.6916 1.59022 13.1303,1.8251 13.7523 – user3780018 Jun 10 '17 at 6:53
  • The third row doesn't have the same order! – user3780018 Jun 10 '17 at 6:59
  • I'm checked it and it work for many files, if there is different count of rows it put blank line. – Krzysztof Stasiak Jun 11 '17 at 9:56
  • I delete an , sign from code that was mistake. – Krzysztof Stasiak Jun 11 '17 at 9:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.