Aside from the problem in your sed
expression (that it doesn't allow space after =
), you don't really need a pipeline here.
grep
would suffice:
grep -m 1 -oP 'dropped\s*=\s*\K\d+' logfile
You could have fixed your sed
expression by permitting space after the =
:
sed -n 's/.*= *\([0-9]*\) (.*/\1/p'