When I used this command on Red Hat Linux
/usr/sbin/ss -i
I get the following output below:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ts sack wscale:2,2 rto:204 rtt:4.5/6.5 ato:40 cwnd:3
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ts sack wscale:2,2 rto:213 rtt:13.875/18.5 ato:40
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ts sack wscale:2,2 rto:201 rtt:1.875/0.75 ato:40
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ts sack wscale:9,2 rto:201 rtt:1.875/0.75 ato:40
Whenever I try to pipe grep
to that command ex
:
/usr/sbin/ss -i | grep <SOME_IP_ADD>
I have this output
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
ESTAB 0 0 <IP_ADD:PORT> <IP_ADD:PORT>
Notice that grep didn't include this:
ts sack wscale:2,2 rto:204 rtt:4.5/6.5 ato:40 cwnd:3
because its on another line. So how do I adjust the column width whenever I use this command or other Linux commands for that matter. So that the output will not word-wrap or go to the next line? Are their better ways of doing this?
Best Answer
If your grep has it, try the
-A1
option.It looks like it is not a case of wrapping, but that the entry is on a separate line.
Look at
Context Line Control
inman grep
.An alternative would be to use
as in:
Then you won't get the surrounding dashes which context gives.
An alternative could be sed:
awk: