I have a simple task:
From such output:
[root@localhost:~]# racoonctl -s /var/racoon/racoon.sock ss isakmp
Destination Cookies Created
89.208.102.86.500 d0a641ed0aa7bfe9:7ae3428b08fab146 2013-02-04 15:32:18
need to take only IP address string and date string (in different requests).
For IP I have wrote following regexp:
[root@localhost:~]# racoonctl -s /var/racoon/racoon.sock ss isakmp | sed -ne 's/^\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p'
89.208.102.86
But for date doesn’t work
[root@localhost:~]# racoonctl -s /var/racoon/racoon.sock ss isakmp | sed -ne 's/^.*\([0-9]\{4\}\(\-[0-9]\{2\}\)\{2\}\ \([0-9]\{2\}:\)\{2\}[0-9]\{2\}\)$/\2/p'
[root@localhost:~]#
Can not understand where is the error?
Also I want to change /(expression/) and /{expression/} using flag -r, but have no idea how will do it
Thank you in advance
P.S.
also I know about alternative variant:
[root@localhost:~]# racoonctl -s /var/racoon/racoon.sock ss isakmp |awk -F\. '/[0-9]/ {print $1"."$2"."$3"."$4}'
89.208.102.86
[root@localhost:~]# racoonctl -s /var/racoon/racoon.sock ss isakmp | awk '/[0-9]/ {print $3 " " $4}'
2013-02-04 15:32:18
But I want to do it on sed, for my future hadrly tasks.
You can use following sed:
to get your date.