reformat ugly time format

hi all,

i am working in bash and grep a timestamp from a file. now i need to do some calculation on it. unfortunately it is in an ugly time format:

Tue Oct 11 10:11:39 2011

does anyone of you know how to reformat that ugly string so that i get the seconds from the beginning of this decade

something similiar to the result of the bash command "date +%s" would be great.

work with this:

date -d "Tue Oct 11 09:53:25 2011" +%s
#  or 
string="Tue Oct 11 09:53:25 2011"
secs=$( date -d "$string" +%s  )
echo $secs
1 Like

hi jim,
thanks for your great hint - it works perfectly.

here the complete line which works just perfectly for me:

date -d "$(grep 'some conditions' file_2_be_greped_from | awk 'BEGIN { FS="[|]*" } ; { print $3}')" +%s