Created
October 17, 2017 13:14
-
-
Save johndstein/040b8d7aec9a11f127d46567185a4426 to your computer and use it in GitHub Desktop.
Add fixed value column to CSV file
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
#!/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