Created
October 12, 2018 21:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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