0

file1

1
2
3
4

file2

5
6
7
8 

result I want

1   
5
2
6
3
7
4
8 

which file1 alternative with file2

not like

1
2
3
4
5
6
7
8

can I merge file like this?

goldenasian
  • 264
  • 1
  • 2
  • 9

2 Answers2

2

As an alternative to the sed method suggested by @Michael, you can also use the paste command, in this case: paste -d \\n file1 file2

bisen2
  • 486
  • 1
  • 4
  • 10
-1

Have you tried the below in the linux command line?

cat file2.txt >> file1.txt

This will append the text in file1 to file 2.

Edit: Having seen your query is referring to intertwining the files, I think this article will help you using the 'sed' command: https://unix.stackexchange.com/questions/288521/with-the-linux-cat-command-how-do-i-show-only-certain-lines-by-number

Michael
  • 67
  • 1
  • 5
  • yes I aleady did, but in that case it will just add up file2 after file1 – goldenasian May 30 '20 at 20:14
  • if you see sample up there 1st line of file2 is appended after 1st line of file 2 then 2nd line after 2nd and so on ..., but with cat command it will just add each file – goldenasian May 30 '20 at 20:16
  • 1
    I have now edited my response with an article on using the 'sed' command. You can use this to merge with bisen2's solution. – Michael May 30 '20 at 20:28