Skip to content

Instantly share code, notes, and snippets.

@grahamlyons
Created November 11, 2016 21:05
Show Gist options
  • Save grahamlyons/0e1359ee93492b4a50f47f6f270cf5a2 to your computer and use it in GitHub Desktop.
Save grahamlyons/0e1359ee93492b4a50f47f6f270cf5a2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
for file in $(ls *.csv)
do
prefix=$(echo ${file} | cut -d'_' -f1)
echo $prefix
tmpfile=$(tempfile)
while read line
do echo "${prefix},${line}" >> ${tmpfile}
done < ${file}
mv ${tmpfile} ${file}
rm ${tmpfile}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment