Last active
December 10, 2015 13:18
-
-
Save nicerobot/4440321 to your computer and use it in GitHub Desktop.
Convert line-oriented output into multi-column output.
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 | |
columns=${1:-4} | |
# Tab separated: | |
${TAB:-false} && awk -v columns=${columns} -v RS='\n' '{ORS=(++i%columns?"\t":"\n");print}END{print "\n"}' | |
# Fixed width: | |
${TAB:-false} || awk -v width=${width} -v columns=${columns} -v RS='\n' '{printf "%-*s%s",width,$0,(++i%columns?"":"\n")}END{print "\n"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment