Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: Merging multiple files, each on a new line

Tags:

linux

bash

I am using cat *.txt to merge multiple txt files into one, but I need each file to be on a separate line.

What is the best way to merge files with each file appearing on a new line?

like image 444
Marco Avatar asked Apr 05 '10 02:04

Marco


People also ask

How do I combine multiple files into one in Linux?

To append content after you merge multiple files in Linux to another file, use double redirection operator. (>>) along with cat command. Rather than overwriting the contents of the file, this command appends the content at the end of the file.

How do I merge 3 files in Linux?

Overview. We know that we can use the command cat file1 file2 to concatenate multiple files.

Which command is used to combine multiple files in Linux?

Overview. In Unix and Unix-like operating systems (such as Linux), you can use the tar command (short for "tape archiving") to combine multiple files into a single archive file for easy storage and/or distribution.


1 Answers

just use awk

awk 'FNR==1{print ""}1' *.txt 
like image 136
ghostdog74 Avatar answered Oct 14 '22 14:10

ghostdog74