Unix command to concatinate 2 files?

chiwawa626

Lifer
Aug 15, 2000
12,013
0
0
I need to conactinate 2 files but also place text inbetween the two files so the output would like like:
(file 1)
new text
(file2)

Can someone show me the command, i know it has to do with cat and redirecting output...but im confused.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: chiwawa626
I need to conactinate 2 files but also place text inbetween the two files so the output would like like:
(file 1)
new text
(file2)

Can someone show me the command, i know it has to do with cat and redirecting output...but im confused.

echo 'new text' > file 3 && cat file1 file3 file2 > final_file

EDIT: or echo 'new text' >> file1 && echo `cat file2` >> file1
:D
 

chiwawa626

Lifer
Aug 15, 2000
12,013
0
0
I just ended up doing the following:

cat file1 /dev/tty file2 > file3

So it just opens the terminal to type into the file then after you hit ctrl-d it finishes by placing file2 in there.