티스토리 뷰

이 명령 sed "s/$(ip-ifconfig)//"은 IP 주소를 빈 문자열로 바꿉니다. 이것은 아마도 당신이 원하는 것이 아닙니다. 또한 ip-ifconfig 명령을 모릅니다. 단일 IP 주소를 제공한다고 가정합니다.

이를 달성하는 대략적인 방법은 IP 주소를 포함하는 모든 행을 억제하는 것입니다 (예 : 다음 두 예 중 하나).

tshark -T fields -e ip.addr -E aggregator=" " | grep -v "$(ip-ifconfig)"
tshark -T fields -e ip.addr -E aggregator=" " | sed "/$(ip-ifconfig)/d"

이 솔루션은 그다지 강력하지 않습니다. IP 주소가 192.168.1.1이면 위의 패턴도 192.168.1.10 또는 192.168.1.123과 일치합니다. 각괄호를 사용하여 전체 단어를 일치시킬 수 있습니다.

tshark -T fields -e ip.addr -E aggregator=" " | grep -vE "\<$(ip-ifconfig)\>"
tshark -T fields -e ip.addr -E aggregator=" " | sed "/\<$(ip-ifconfig)\>/d"

이것은 대부분의 경우 작동합니다. IP 주소의 점은 이상적으로 이스케이프되어야합니다. 그렇지 않으면 정규식에서 모두 일치하는 문자로 사용됩니다.

마지막으로 tshark에서 디스플레이 필터를 간단히 사용할 수 있습니다.

tshark -T fields -e ip.addr -E aggregator=" " -Y "ip.addr != $(ip-ifconfig)"

이렇게하면 매우 복잡한 필터를 만들 수 있습니다.

-------------------

을 찾고있었습니다 tshark -l.

 -l        Flush the standard output after the information for each packet is printed.  (This is not, strictly speaking, line-buffered if -V was specified; however, it is the same as line-
           buffered if -V wasn't specified, as only one line is printed for each packet, and, as -l is normally used when piping a live capture to a program or script, so that output for a
                      packet shows up as soon as the packet is seen and dissected, it should work just as well as true line-buffering.  We do this as a workaround for a deficiency in the Microsoft
                                 Visual C++ C library.)
                                 
                                            This may be useful when piping the output of TShark to another program, as it means that the program to which the output is piped will see the dissected data for a packet as soon
                                                       as TShark sees the packet and generates that output, rather than seeing it only when the standard output buffer containing that data fills up.
                                                       


출처
https://stackoverflow.com/questions/39916046
댓글
공지사항
Total
Today
Yesterday
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30