Skip to content

Instantly share code, notes, and snippets.

@seathief
Created August 26, 2020 04:43
Show Gist options
  • Save seathief/c5f62cb3353e90b341f62bcd347b9d3e to your computer and use it in GitHub Desktop.
Save seathief/c5f62cb3353e90b341f62bcd347b9d3e to your computer and use it in GitHub Desktop.
merge utf-8 BOM csv files into single file and keep header from first file.
#!/bin/bash
# ref:https://zzz.buzz/2016/07/30/bom-in-iconv/
# ref:https://stackoverflow.com/questions/16890582/unixmerge-multiple-csv-files-with-same-header-by-keeping-the-header-of-the-firs
for filename in *.csv; do
sed -i 's/\xef\xbb\xbf//' $filename
done
awk 'FNR==1 && NR!=1{next;}{print}' *.csv > merge-bom.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment