How to suck a substring from a string?

Write a script on bash. he is looking for in the logs, I need lines, then I need from the string to suck it to a file, I need the substring .
here is the line:
May 31 04:12:10 SSCK01 dhcpd[16691]: [ID 988538 local7.notice] [tid:30] NTCE DHCPOP(101) Protocol: there is no answer from STRING-K01 PON 1/1/02/01:12.1.1 (chAddr=00:13:77:6d:44:6b) via 81.91.202.1.

here it is necessary to take a bite:
STRING-K01 PON 1/1/02/01:12.1.1
I eat it using awk {print $13,$14,$15} but then noticed that the number of fields changes in the other rows and wykonywac not what we need.
I think it is correct to suck it against a regular expression:
grep -E -o "\b[STRING]+[X00,K01-99]+" "+[PON]+" "+[1/1/01-09/01-09/:01-64.1.1]\b"

but this design error.
July 8th 19 at 16:17
4 answers
July 8th 19 at 16:19
Solution
if the "STRING" and " PON " are determining that you can do this:

$ awk -F" STRING| PON " '{print "STRING"$2" PON "$3 }' | awk '{print $1" "$2" "$3}' fileIn >> fileOut
this design worked, thank you!!! - Nikki commented on July 8th 19 at 16:22
July 8th 19 at 16:21
Solution
[guest@localhost ~]$ s="May 31 04:12:10 SSCK01 dhcpd[16691]: [ID 988538 local7.notice] [tid:30] NTCE DHCPOP(101) Protocol: there is no answer from STRING-K01 PON 1/1/02/01:12.1.1 (chAddr=00:13:77:6d:44:6b) via 81.91.202.1."
[guest@localhost ~]$ 
[guest@localhost ~]$ echo "$s" | sed 's/.* from //; s/ (.*//'
STRING-K01 PON 1/1/02/01:12.1.1
[guest@localhost ~]$
July 8th 19 at 16:23
cat your_log | perl -e 'while(<>){ if ($_ =~/.*from\s+(STRING.*)\s+\(chAddr/){ print $1."\n"; }}'

well either way
cat your_log | grep -E-o 'STRING-K\d{2}\s+PON\s+\d\/\d\/\d{2}\/\d{2}:\d{2}\.\d\.\d'
I have SunOs 5.10 /usr/xpg4/bin/grep - Nikki commented on July 8th 19 at 16:26
perl - e didn't work either - Nikki commented on July 8th 19 at 16:29
watch man on grepo. poidee all right shall operate the regular season example% /usr/xpg4/bin/grep -e 'abc' -e 'def'
example% /usr/xpg4/bin/grep -E 'abc|def'
example% /usr/xpg4/bin/grep -E-e 'abc|def'
example% /usr/xpg4/bin/grep -E-e 'abc' -e 'def' - Nikki commented on July 8th 19 at 16:32
: set to gnu grep. In Solaris it ggrep the idea is called - Nikki commented on July 8th 19 at 16:35
there root no. so can using only what you have. ( - Nathan_Gaylord commented on July 8th 19 at 16:38
July 8th 19 at 16:25
cat your_log | grep -E-o 'STRING-K\d{2}\s+PON\s+\d\/\d\/\d{2}\/\d{2}:\d{1,2}\.\d\.\d'

found online editor regexps. this reguraly correct but why not worked.
can someone come in handy a couple of editors Regexp www.pcre.ru/eval and www.regextester.com - Nikki commented on July 8th 19 at 16:28

Find more questions by tags grepAWKbash