Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

awk count if

# Basic syntax:
awk '{ if ( condition ) { count += 1; }} END { print count }' your_file

# Example usage:
# Count all fields in your_file that don't have "*" in field 3
awk '{ if ($3 != "*" ) { count += 1; }} END { print count }' your_file
# Note, explicitly setting your_file's field delimiter with 
#	"BEGIN { FS="<input_delimiter>" };" might be needed for non-standard 
#	delimiters
Source by www.unix.com #
 
PREVIOUS NEXT
Tagged: #awk #count
ADD COMMENT
Topic
Name
6+9 =