Skip to content

Instantly share code, notes, and snippets.

@johndstein
Created October 17, 2017 13:14
Show Gist options
  • Save johndstein/040b8d7aec9a11f127d46567185a4426 to your computer and use it in GitHub Desktop.
Save johndstein/040b8d7aec9a11f127d46567185a4426 to your computer and use it in GitHub Desktop.
Add fixed value column to CSV file
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
echo ""
echo "Usage: $me HEADER VALUE"
echo ""
echo " We read from STDIN and write to STDOUT."
echo ""
exit 1
fi
cat /dev/stdin | sed "1 s/$/,$1/" | sed "1 ! s/$/,$2/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment