Created
August 8, 2020 00:42
-
-
Save domargan/5141965cd19e37047bfd34ddc4c4ab53 to your computer and use it in GitHub Desktop.
Sorting markdown tables by column
This file contains 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
#!/bin/bash | |
# Credit: https://christiantietze.de/posts/2017/05/sort-markdown-tables-shell/ | |
# First argument is a path to table file in markdown format | |
# Second argument is the key column+1 to sort by | |
(head -n 2 $1 && tail -n +3 table.md | sort --field-separator=\| --key=$2) > sorted_table.md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment