How to merge two files?

Dear Frens,

I have two files and need to merge into one file. Like

File_1 :

Field1 Field2
1         4

File_2 :

Field1 Field2
3         5

I need one single output as
File_1 :

Field1 Field2
1         4
3         5

This means taking header from either file.

Please help me. Your small help could save my lots of time

Thank you so much

What have you tried? We are here to help you learn; not to act as your unpaid programming staff.

What operating system are you using?

What shell are you using?

Thank you for a prompt response. I have used cat command but this simply merged two files. I need to get header+ data from one file and only data from a second file. I am using Window 7.

Assuming that you have loaded something like Cygwin on your Windows system and are using the shell in that package, try:

head -n +2 File_2 >> File_1

which will add everything starting with the 2nd line in File_2 to the end of File_1 .

Thank you again. I tried the mentioned code but this code merged first two line from the second file i.e. header and extra one record.
I have used the same code, only file name is different.

---------- Post updated at 08:30 PM ---------- Previous update was at 08:14 PM ----------

Hi Don,

I used -- sed '1d' test2.txt >> test1.txt

It worked.

Thank you so much for your help. AtleastI learned how we can append data from one file to another.

Please show us the output you get (in CODE tags) from the command:

od -bc File_2

where File_2 is replaced with the real name of your 2nd file. And please show us the EXACT command line you used.

Working on Windows systems, we always have to be concerned about text file formats. On UNIX and similar systems, lines are terminated by a <newline> character. On Windows, lines are separated by the character pair <carriage-return><newline>. Standard UNIX system text handling utilities assume that files being processed are UNIX format text files.

Hi,
when i test od -bc test1.txt , the result is

0000300 063 062 174 061 065 063 062 174 103 064 174 060 063 012 060 060
       3   2   |   1   5   3   2   |   C   4   |   0   3  \n   0   0
0000320 060 064 066 070 070 104 174 064 066 070 070 174 064 066 070 070
       0   4   6   8   8   D   |   4   6   8   8   |   4   6   8   8
0000340 174 105 064 174 061 070 012 060 060 060 071 071 061 061 102 174
       |   E   4   |   1   8  \n   0   0   0   9   9   1   1   B   |
0000360 071 071 061 061 174 071 071 061 061 174 101 064 174 060 071 012
       9   9   1   1   |   9   9   1   1   |   A   4   |   0   9  \n

Sorry, I should have said tail instead of head . The od output shows that you have UNIX format text files, so that isn't a problem in this case. Next time, try:

tail -n +2 File_2 >> File_1

Sure I will try that too. Thank you so much for you help.

Have a good night.