Skip to content

Instantly share code, notes, and snippets.

@arc279
Last active April 12, 2017 10:00
Show Gist options
  • Save arc279/253fbe6d7c4e944e1c93e879e39b24a4 to your computer and use it in GitHub Desktop.
Save arc279/253fbe6d7c4e944e1c93e879e39b24a4 to your computer and use it in GitHub Desktop.
bash で array_zip
#!/bin/bash
a=(1 2 3 4 5)
b=(a b c d e)
paste -d ',' <(printf "%s\n" "${a[@]}") <(printf "%s\n" "${b[@]}")
1,a
2,b
3,c
4,d
5,e
#!/bin/bash
a=$(head -n 1 a.tsv | datamash transpose)
tail -n +2 a.tsv | while IFS=$'\n' read x; do
echo "$x" | datamash transpose | paste -d '=' <(echo "${a[@]}") - | jo
done | jq .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment