I want to append file text after last word of another file on a UNIX system.
File 1
& program executed successfully
File 2
Hello
World
This is a sample output
I want to copy the first two words and paste them after the last word of file 2.
Expected output:
File3
Hello
World
This is a sample output & program
File2 has a newline character at the end, so when I tried using cat
, it prints on a new line instead of printing after the last word on the same line. Please suggest a solution using UNIX commands and the bash shell.