Reputation: 31
I have two files:
file1.txt
apple
orange
banana
file2.txt
red
white
blue
What I would like to end up with is this:
file3.txt
apple
red
orange
white
banana
blue
Any help would be greatly appreciated!
Upvotes: 3
Views: 3337
Reputation: 14949
In sed
,
sed 'R file2.txt' file1.txt > file3.txt
In Bash
,
while IFS= read -r lineA && IFS= read -r lineB <&3 ; do echo "$lineA"; echo "$lineB"; done <file1.txt 3<file2.txt > file3.txt
Upvotes: 4
Reputation: 606
I am adding an awk solution:
awk '1;getline <"file2"' file1 >newfile
this one-liner works for your example.
Upvotes: 2
Reputation: 123458
You can use paste
:
paste -d'\n' file1.txt file2.txt > file3.txt
Upvotes: 11