Skip to main content
added 461 characters in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from package moreutils:

pv *.log | grep -vc '^.\{301\}'

If you want to get line number per file:

grep -vc '^.\{301\}' *.log

and if you want to get the total from the above command:

grep -vc '^.\{301\}' *.log | awk -F':' '{c+=$NF} END {print c}'

Depending on the data, although we don't usually pipe grep with awk, it could be faster than cat & grep, if there are many very long input lines, the pipe here is used just for a small amount of data, numbers and filenames.

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from package moreutils:

pv *.log | grep -vc '^.\{301\}'

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from package moreutils:

pv *.log | grep -vc '^.\{301\}'

If you want to get line number per file:

grep -vc '^.\{301\}' *.log

and if you want to get the total from the above command:

grep -vc '^.\{301\}' *.log | awk -F':' '{c+=$NF} END {print c}'

Depending on the data, although we don't usually pipe grep with awk, it could be faster than cat & grep, if there are many very long input lines, the pipe here is used just for a small amount of data, numbers and filenames.

deleted 6 characters in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from package moreutils:

catpv *.log | pv | grep -vc '^.\{301\}'

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from moreutils:

cat *.log | pv | grep -vc '^.\{301\}'

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from package moreutils:

pv *.log | grep -vc '^.\{301\}'
added 153 characters in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from moreutils:

cat *.log | pv | grep -vc '^.\{301\}'

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.

With grep:

cat *.log | grep -vc '^.\{301\}'

To match lines with length <=300 we grep with -v (invert match) for any 301 characters, as the search pattern is limited to one line for grep. Pattern is anchored at the beginning of the line with ^. And -c counts the matching lines.


If you want to have some basic progress indicator, you can use pv from moreutils:

cat *.log | pv | grep -vc '^.\{301\}'
added 6 characters in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40
Loading
added 1 character in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40
Loading
added 1 character in body
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40
Loading
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40
Loading