Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

Combining CSVs on a Mac Using Terminal

See instructions further down on how to open a terminal session at the folder level.

Quick Scripts

Script: Merge CSVs without Duplicating Header Rows

awk '(NR == 1) || (FNR > 1)' *.csv > combinedFile.csv

Script: Merge CSVs and Duplicate Header Rows

Note: This is almost never the command you want to use ↓

cat *.csv >combined.csv


Opening a Terminal Session at the Folder

Merging CSV files can be done easily using Terminal on a Mac. Follow these steps:

  1. Put all of the CSV files you want to merge into a single folder.

  2. Right-click the folder, go to services, and click "Open New Terminal
    image.png

  3. Once you have a Terminal instance open, copy and paste the command below into Terminal and hit enter.

Terminal Command:

cat *.csv >combined.csv

That's it. You will now have a merged CSV inside that folder named combined.csv.


Related Resources:

Aliases:

  • Combining CSV files using terminal

  • Concatenating CSV files using terminal

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.