Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cat files in linux vertically? [duplicate]

Tags:

linux

cat

I have n files containing one line and want to concatenate them:

Input files:

file_1
A B C

file_2 
1 2 3 

Desired console ouput result:

A B C
1 2 3 

But with:

$ cat file_1 file_2 

I get:

A B C1 2 3 
like image 765
shaq Avatar asked Dec 04 '25 03:12

shaq


1 Answers

Try

echo | cat file_1 - file_2

Alternatively, terminate the last line of file_1 with a new-line symbol.

Yet another way:

$ echo > n
$ cat file_1 n file_2 n file_1 n file_2 n
A B C
1 2 3
A B C
1 2 3
like image 190
Maxim Egorushkin Avatar answered Dec 06 '25 18:12

Maxim Egorushkin