-
-
Save arc279/253fbe6d7c4e944e1c93e879e39b24a4 to your computer and use it in GitHub Desktop.
bash で array_zip
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/bash | |
a=(1 2 3 4 5) | |
b=(a b c d e) | |
paste -d ',' <(printf "%s\n" "${a[@]}") <(printf "%s\n" "${b[@]}") |
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
1,a | |
2,b | |
3,c | |
4,d | |
5,e |
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/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