-
-
Save lsloan/b6b219370916d39ec1af23cfc74bd6d0 to your computer and use it in GitHub Desktop.
jq, JSON: Sort JSONL by using jq's `--slurp` option to treat it as a JSON array
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
#!/bin/sh -- | |
# Execute with an argument containing the name of the property to be | |
# used for sorting. | |
# Improved according to a suggestion from @pkoppstein in response to my | |
# support issue: | |
# https://github.com/stedolan/jq/issues/1447#issuecomment-314918635 | |
jq --slurp --compact-output 'sort_by(.'${1}')[]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment