Добрый день. Записываю результат выполнения программы в файл следующей командой
sudo trafshow -i enp0s3 > file.txt
На выходу получаю следующее:
[?1049h [22;0;0t [1;24r (B [m [4l [?7h [39;49m [39;49m (B [m [H [2JSource [1;27HDestination [1;53HProtocol Size [75GCPS
[2d (0 [0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq (B [23;1H (0 [0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq (B [24;1H (0 [0m (Benp0s3 [24;27H0 Flows [24;53HTotal: 0 [75G0 [HSource [20X [1;27HDestination [15X [1;53HProtocol Size CPS [K
[2d (0 [0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq (B [3;1H (0 [0m (B [K [4d [K [5d [K [6d [K [7d [K [8d [K [9d [K [10d [K [11d [K [12d [K [13d [K [14d [K [15d [K [16d [K [17d [K [18d [K [19d [K [20d [K [21d [K [22d [K [24;80H [HSource [20X [1;27HDestination [15X [1;53HProtocol Size CPS [K
[2d (0 [0mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq (B [3;1H (0 [0m (B [K [4d [K [5d [K [6d [K [7d [K [8d [K [9d [K [10d [K [11d [K [12d [K [13d [K [14d [K [15d [K [16d [K [17d [K [18d [K [19d [K [20d [K [21d [K [22d [K [24;80H [HSource [20X [1;27HDestination [15X [1;53HProtocol Size CPS [K
[2d (0...........................
Нашел в инернете как преобразовать в читаемый вид, следующую команду
tr -s "[\027]" "\n" < /1.txt |\
sed -n '/Source/,${
s/\(^.*\).$/\1/
/^.*qqqqqqqq.*$/d
s/^[a-zA-Z]\(.*\)/\1/
s/^[0-9][a-zA-Z]\(.*\)/\1/
/ [ ]*$/s/ [ ]*$//
/^.......................*/p
}' > /2.txt
Получаю следующее
1;53HProtocol Size CPS
0;7m192.168.0.1,domain 10.0.2.15,53512 udp 374
31m10.0.2.15,53512 192.168.0.1,domain udp 140
1;53HProtocol Size CPS
0;7m13.33.243.3,https 10.0.2.15,52224 tcp 9K
31m10.0.2.15,52224 13.33.243.3,https tcp 1510
192.168.0.1,domain 10.0.2.15,37755 udp 804
10.0.2.15,56486 34.107.221.82,http tcp 432
10.0.2.15,56484 34.107.221.82,http tcp 427
192.168.0.1,domain 10.0.2.15,40416 u1;53HProtocol Size CPS
0;7m192.168.0.1,domain 10.0.2.15,53512 udp 374
31m10.0.2.15,53512 192.168.0.1,domain udp 140
1;53HProtocol Size CPS
0;7m13.33.243.3,https 10.0.2.15,52224 tcp 9K
31m10.0.2.15,52224 13.33.243.3,https tcp 1510
192.168.0.1,domain 10.0.2.15,37755 udp 804
10.0.2.15,56486 34.107.221.82,http tcp 432
10.0.2.15,56484 34.107.221.82,http tcp 427
192.168.0.1,domain 10.0.2.15,40416 udp 380
192.168.0.1,domain 10.0.2.15,58929 udp 380dp 380
192.168.0.1,domain 10.0.2.15,58929 udp 380
Но почему то не до конца удалил символы. Я выделил жирным.
Помогите исправить это. В линуксе не сильно силен