0

Say I have multiple files x1, x2,x3,x4, all with common header date, time, year, age.

How can I merge them to one singe file X in shell scripting?

File x1:

date time year age
101014 1344 2012 52
111012 1200 2010 49

File x2:

date time year age
140112 1100 2011 54
230113 0500 2005 46

Similiary for other files x3 and x4.

The output should be:

date time year age
101014 1344 2012 52
111012 1200 2010 49
140112 1100 2011 54
230113 0500 2005 46

and the similar data from x3 and x4.

0

An awk solution:

$ awk 'NR == 1 {print;next} FNR != 1' file1 file2
date time year age
101014 1344 2012 52
111012 1200 2010 49
140112 1100 2011 54
230113 0500 2005 46
| improve this answer | |
0

Easy, you gonna use the join command. Don't remember by heart the argument. See the manual man join for more information.

| improve this answer | |
  • If you don't remember the argument, please don't post an answer. Answers should actually answer the question. – terdon Sep 26 '14 at 14:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.