Results 1 to 2 of 2
i got text file and contain....
SKYPE Dec 11 09:26:05 IN=eth0 OUT=eth1 SRC=75.38.161.80 DST=192.168.1.56 PROTO=UDP SPT=30645 DPT=12630 LEN=66
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=118.109.39.86 PROTO=UDP SPT=12630 DPT=15889 LEN=75
...
- 12-11-2008 #1Just Joined!
- Join Date
- Jun 2007
- Posts
- 84
how to cut string with wildcard (sed)
i got text file and contain....
SKYPE Dec 11 09:26:05 IN=eth0 OUT=eth1 SRC=75.38.161.80 DST=192.168.1.56 PROTO=UDP SPT=30645 DPT=12630 LEN=66
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=118.109.39.86 PROTO=UDP SPT=12630 DPT=15889 LEN=75
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=89.139.194.176 PROTO=UDP SPT=12630 DPT=14056 LEN=75
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=213.250.11.235 PROTO=UDP SPT=12630 DPT=25241 LEN=75
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=212.214.188.162 PROTO=UDP SPT=12630 DPT=54824 LEN=75
i want to cut LEN*,PROTO* and DPT*
i use
cat text.file | sed 's/DPT//'
not working it's cut DPT only
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=212.214.188.162 PROTO=UDP SPT=12630 DPT=54824 LEN=75
result
SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=212.214.188.162 PROTO=UDP SPT=12630 =54824 LEN=75
anyone help me.!!!
- 12-11-2008 #2Just Joined!
- Join Date
- Oct 2004
- Posts
- 62
You can use cut "delimited" with '='.and then piping
the output through the 2nd cut "delimited" with blank.
The results are:Code:cat file| cut -d "=" -f9 | cut -d " " -f1 > len.txt cat file| cut -d "=" -f6 | cut -d " " -f1 > proto.txt cat file| cut -d "=" -f8 | cut -d " " -f1 > dpt.txt
... obviously, one per line.Code:len.txt --> 66 75 75 75 75 proto.txt --> UDP UDP UDP UDP UDP dpt.txt --> 12630 15889 14056 25241 54824


Reply With Quote