Skip to main content
added 75 characters in body
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

Yet another way is to use the s///s/// command in a scalar context:

perl -lne '$c += s/\t0\b//g == 3}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Gnu grep can also help you:

grep -cP '(.*\t0\b.*){3}' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

Yet another way is to use the s/// command in a scalar context:

perl -lne '$c += s/\t0\b//g == 3}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

Yet another way is to use the s/// command in a scalar context:

perl -lne '$c += s/\t0\b//g == 3}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Gnu grep can also help you:

grep -cP '(.*\t0\b.*){3}' file 
added 128 characters in body
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

Yet another way is to use the s/// command in a scalar context:

perl -lne '$c += s/\t0\b//g == 3}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

Yet another way is to use the s/// command in a scalar context:

perl -lne '$c += s/\t0\b//g == 3}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 
deleted 2 characters in body
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c++'$c if+= 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c++ if 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 

Use Perl to count the number of lines which see a zero surrounded on the left by a TAB and to the right by a word boundary, three times. In the end print the line count of such lines.

perl -lne '$c += 3 == (() = /\t0\b/g)}{print $c' file 7 

Another way to do it is by looking at the fields:

perl -F'\t' -lane '$c++ if 3 == grep ! $_, @F[1..$#F]}{print $c' file 

We use Gnu awk to do this:

awk -F'\t' ' { gsub(FS, FS FS) $0 = $0 FS if ($0 != gensub(FS"0"FS, "", 3, $0)) ++c } END{print c} ' file 
added 204 characters in body
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3
Loading
added 120 characters in body
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3
Loading
Source Link
Rakesh Sharma
  • 856
  • 1
  • 5
  • 3
Loading