Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash print count of unique words in column

# Example usage:
awk -F '	' '{print $7}' input_file | sort | uniq -c
# Where: 
# 	- awk returns the 7th tab-delimited column/field of the input_file
# 	- sort sorts the entries so that duplicate entries are adjacent
# 	- uniq -c returns the counts of each type of element

# Note:
#	- add "| cut -c 9-" to remove the counts if you only want the unique values
#		found in the column/field
#	- the entrez-direct tool (conda install entrez-direct) has the command sort-uniq-count
#		and sort-uniq-count-rank that do a better job of formatting the output
Source by unix.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #bash #print #count #unique #words #column
ADD COMMENT
Topic
Name
1+7 =