Skip to content

Instantly share code, notes, and snippets.

@francois-blanchard
Created August 17, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francois-blanchard/ef6ad2ef14987fcd784b33bc76cb9960 to your computer and use it in GitHub Desktop.
Save francois-blanchard/ef6ad2ef14987fcd784b33bc76cb9960 to your computer and use it in GitHub Desktop.
Concat csv files in current directory (mac osx version)

Intro

This script concat all csv file (by default order) in one csv file result.csv only with first and second columns. Additional behaviour : skip 8 first lines (header) and 5 last lines (footer)

Requirements

brew install coreutils

Tips

Replace ghead by head for linux user

#!/bin/bash
rm -f result.csv
for x in *.csv; do
tail -n +8 "$x" | ghead -n -5 | cut -d, -f1,2 | grep "^\"" >> result.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment