Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Created November 8, 2018 18:58
Show Gist options
  • Save rms1000watt/4b46c90caa65127c3751c8ba9db266ed to your computer and use it in GitHub Desktop.
Save rms1000watt/4b46c90caa65127c3751c8ba9db266ed to your computer and use it in GitHub Desktop.
sed in OS X add newline at beginning of file
#!/usr/bin/env bash
header="col1,col2,col3"
cat << EOF > raw.csv
4,1,5
3,1,4
6,8,11
EOF
lf=$'\n'; sed -i.bak "1s;^;$header\\$lf;" raw.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment