I want to get a date which is in a string with shell script for an example:
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaSun Apr 07 10:38:34 EEST 2013jnad
dddddddddddddddansdpaojhndpaosdjnad
How I can extract a date wich is in a string with shell script?
I don't know if your example text is really reflecting your real data. And I think the EEST
is a typo? If work on the example you gave:
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaSun Apr 07 10:38:34 EEST 2013jnad
dddddddddddddddansdpaojhndpaosdjnad
this line should do the job:
grep -o '[A-Z].*[0-9]'
for example:
kent$ echo " dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaojhndpaosdjnad
dddddddddddddddansdpaSun Apr 07 10:38:34 EEST 2013jnad
dddddddddddddddansdpaojhndpaosdjnad"|grep -o '[A-Z].*[0-9]'
Sun Apr 07 10:38:34 EEST 2013