Skip to content

Instantly share code, notes, and snippets.

@grohiro
Created January 16, 2015 08:49
Show Gist options
  • Select an option

  • Save grohiro/47cd1eb14e97e4ab2417 to your computer and use it in GitHub Desktop.

Select an option

Save grohiro/47cd1eb14e97e4ab2417 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Convert TSV data to backlog Wiki table format.
function read_stdin() {
IFS= read line
while [ "x$line" != "x" ]; do
if [ "x$contents" != "x" ]; then
contents=$contents"\n"
fi
contents=$contents$line
IFS= read line
done
echo "$contents"
}
if [ $# = 0 ]; then
contents=`read_stdin`
else
contents=`cat $1`
fi
echo -e "$contents" | sed -e 's/^/|/' -e 's/$/|/' -e 's/ /|/g' -e '1s/$/h/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment