Artificial intelligent assistant

Count rows with specific integer in a column I have 6 columns, each with multiple rows. I want to count the number of rows which have the integer 4 or 5 in the fifth column. A1 jhfj jdhfjkhd kdkfjjh 5 jhsdjkfh A2 ujhf jhdfhsd dsfkks 4 jhsdfjhs A3 jhfj jdhfjkhd kdkfjjh 5 jhsdjkfh A4 jhfj jdhfjkhd kdkfjjh 5 jhsdjkfh A5 ujhf jhdfhsd dsfkks 4 jhsdfjhs In the example presented, the result should be three for lines with a 5, and two for lines with a 4.

Using only `awk`:


awk '
$5==4{c4++};
$5==5{c5++};
END{
print "Fours: "c4;
print "Fives: "c5;
}' your_file


or `perl`:


perl -lane '
$count{$F[4]}++;
END{
print "Fours: $count{4}";
print "Fives: $count{5}"
}' your_file

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy bb0759883612c2bd02ddadde25583d42