> For the complete documentation index, see [llms.txt](https://til.duyet.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.duyet.net/data-engineering/shell/merging-contents-of-multiple-.csv-files-into-single-.csv-file.md).

# Merging contents of multiple .csv files into single .csv file

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

Both NR and FNR represent the number of the line being processed (1 based index). FNR is the current line within each File while NR is the current total Number of Records across all files.&#x20;

* (NR == 1) is including the first line of the first file (header),&#x20;
* (FNR > 1) skips the first line of each subsequent file.
