Last active
December 18, 2015 21:09
-
-
Save jacob-ogre/5845502 to your computer and use it in GitHub Desktop.
bash and awk: functions and aliases for counting columns in tab-, comma-, and space-delimited files. Goes nicely in .bashrc/.bash_profile.
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
function tab_ncol { | |
awk 'BEGIN {FS="\t"} ; END{print NF}' $1; | |
} | |
alias tncol='tab_ncol' | |
function comma_ncol { | |
awk 'BEGIN {FS=","} ; END{print NF}' $1; | |
} | |
alias cncol='comma_ncol' | |
function space_ncol { | |
awk 'BEGIN {FS=" "} ; END{print NF}' $1; | |
} | |
alias sncol='space_ncol' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment