bash - shell tool (awk/grep/sed etc) to remove text after number and before a fixed marker -
i have lines pattern
<positive_integer> <texta(which may include integer)> | <larger_integer> <texta>
for instance:
1544 input packet chains processed length greater 4 | 1545 input packet chains processed length greater 4
i'm not sure whitespace rules there are, may tab or spaces there. think second texta same first maybe there in netstat output might not true.
if helps, working on output of diff -y filea fileb
filea , fileb lines came netstat -s
@ different times — after bit of filtering:
based on suggestions better filtering me is: netstat -s | awk '/error|length|bad|overflow|failure|dropped|loss|unknown|detect|^[[:lower:]]*:$/ { if ($1!= 0) { $1=$1; print} }' (keeping protocol type lines tcp: ip:, call flag, may useful. hope prepend flag each line (store in variables), , maybe add number line after flag shows total data of type.) deprecated code was: netstat -s | awk '{$1=$1};1' | grep -v "^0" | grep "error\|length\|bad\|overflow\|failure\|dropped\|loss\|unknown\|detect"
i hunting down network issues...
i'd out (with simple one-line, pipe-able, os x command):
1544 | 1545 input packet chains processed length greater 4
if it's easy , compact in same command i'd show data change more as
1544 > 1545 input packet chains processed length greater 4
this compact , readable in log file or on screen...
is there better way here filea , fileb first diff -y
?
or better way detect anomalies in network?
my test file:
238 times recovered bad retransmission using dsack | 239 times recovered bad retransmission using dsack 17576 dropped due full socket buffers | 17593 dropped due full socket buffers 14016 data size > data length | 14057 data size > data length 3609 packets unknown/unsupported protocol | 3610 packets unknown/unsupported protocol 13562 packets received unknown multicast group | 13571 packets received unknown multicast group 4909 input packet chains processed length greater 2 | 4911 input packet chains processed length greater 2 1544 input packet chains processed length greater 4 | 1545 input packet chains processed length greater 4 1473 message big failures | 1481 message big failures 13 send failures | 17 send failures
you use command
$ sed -e 's/\([0-9][0-9]*\).*|/\1 |/' < input-file
if input-file
contains
1544 input packet chains processed length greater 4 | 1545 input packet chains processed length greater 4
what out be
1544 | 1545 input packet chains processed length greater 4
Comments
Post a Comment