How to combine CSV files into one on a Mac
By the Analistable team · Updated · 2 min read
Open Terminal, go to the folder with cd, and run awk 'FNR==1 && NR!=1 {next} {print}' *.csv > ../combined.csv. It keeps the header of the first file, skips the header of every other file, and writes the result to the parent folder so the output isn't read as an input. Excel for Mac's Power Query (From Folder) and browser tools also work.
Part of our guide: How to merge CSV files into one
Terminal: one command
- Open Terminal (Applications → Utilities).
- Type
cd(with a space), drag the CSV folder from Finder into the window, and press Enter. - Run the command below.
awk 'FNR==1 && NR!=1 {next} {print}' *.csv > ../combined.csvFNRis the line number within the current file andNRthe line number overall, soFNR==1 && NR!=1matches the first line of every file except the first one.{next}skips that line;{print}prints every other line.> ../combined.csvwrites the result one folder up. If you write into the same folder, a second run would include combined.csv itself.
Files are combined in alphabetical order of their names. awk also adds a missing newline at the end of a file, which plain cat doesn't — with cat, the last row of one file can end up glued to the first row of the next.
Add the file name to each row
awk 'FNR==1 { if (NR==1) print "source," $0; next } { print FILENAME "," $0 }' *.csv > ../combined.csvEvery data row now starts with the file it came from, and the header gets a matching “source” column.
Limits of the command-line approach
| Situation | Better option |
|---|---|
| Files have different or reordered columns | Power Query or a tool that matches headers by name |
| Quoted fields contain line breaks | A CSV-aware tool (Python, csvkit, Power Query) |
| Files use different delimiters or encodings | Power Query, where you set both per source |
Excel for Mac
Microsoft 365 for Mac includes Power Query's From Folder connector: Data → Get Data (Power Query) → From Folder, then combine. The steps and fixes are the same as on Windows — see combining CSV files in Excel. For Excel workbooks rather than CSVs, see combining Excel files on a Mac.
In the browser
The Analistable CSV combiner works in Safari and Chrome. It matches columns by header name, adds a source column and downloads one CSV, and the files stay on your Mac.
Numbers can open CSVs but has no merge feature; copy-pasting between documents is the only built-in option.
Frequently asked questions
- How do I merge CSV files on a Mac without repeating headers?
- In Terminal, run awk 'FNR==1 && NR!=1 {next} {print}' *.csv > ../combined.csv from the folder that contains the files.
- Why does cat *.csv > combined.csv give me extra header rows?
- cat copies every file completely, including each file's header line. Use the awk command, which skips the first line of every file after the first.
- Can Excel for Mac combine CSV files?
- Yes. Microsoft 365 for Mac has Power Query's From Folder connector, which combines every CSV in a folder.