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.

eyoung100
  • 6,252
  • 23
  • 53

2 Answers2

0

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

  • 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
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
cuonglm
  • 153,898