Skip to content

Instantly share code, notes, and snippets.

@oeon
Created October 12, 2018 21:36
Show Gist options
  • Save oeon/59a99d113e61a9ff29940624d2f8e96e to your computer and use it in GitHub Desktop.
Save oeon/59a99d113e61a9ff29940624d2f8e96e to your computer and use it in GitHub Desktop.
use sed (gsed for mac/homebrew) to insert a header into .csv files & remove BOM
#!/bin/bash
for file in *.csv
do
# 1i means insert before line 1
gsed -i 1i"animals,numbers,colors" $file
echo "inserted header in $file!"
gsed -i "s/^\xef\xbb\xbf//" $file
echo "removed BOM in $file!"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment