2

I want to combine two giant file each few hundred megabyte into a single file while ignoring the first line.

I wanted to use awk as I thought it should be the most optimized way. the way I'm doing it only ignores the first line of second file. Any idea how to do make work or if there's a faster way to do it?

awk 'FNR!=NR && FNR==1 {next} 1' 'FNR!=NR && FNR==1 {next} 2' s_mep_{1,2}.out >> s_mep.out
Raymond gsh
  • 363
  • 3
  • 15
  • Possible duplicate of [How to cat two files after each other but omit the last/first line respectively?](https://stackoverflow.com/questions/3600170/how-to-cat-two-files-after-each-other-but-omit-the-last-first-line-respectively) – l'L'l Oct 23 '18 at 01:29
  • The awk suggestion in this article removes the first and the last line of the file. – Raymond gsh Oct 23 '18 at 01:35
  • It's the same basic principle(s) applied... – l'L'l Oct 23 '18 at 01:39

3 Answers3

2
$ awk 'FNR>1' file{1,2} > file_12
karakfa
  • 66,216
  • 7
  • 41
  • 56
2

With sed

(sed '1d' file_1 ; sed '1d' file_2) > new_file
User123
  • 1,498
  • 2
  • 12
  • 26
1

Generalizing to arbitrarily many files ...

for f in ... ; do
  tail -n +2 "$f" >> well_chosen_filename
done
peak
  • 105,803
  • 17
  • 152
  • 177