jycr753 jycr753 - 6 months ago 30
Linux Question

Combine text files preserving separator and formatting

Is possible to have a sed or cat command to merge two text files? for example:

File 1:


File 2:


How to get an output like this?


Because when I do
cat file1 file2 > file-merged
does created in the wrong format for me.

Answer Source

The paste command will do this. For example:

$ paste -d ';' file1.txt file2.txt

'paste' merges the corresponding lines in both files. The '-d' sets the delimiter added between the lines.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download