How can I convert the following into epoch using date?:
oldDate="Dec 23 17:24:13 2022"
date -d $oldDate +%s
date: extra operand ‘17:24:13’
>Solution :
You need to wrap your variable in quotes, like so:
oldDate="Dec 23 17:24:13 2022"
date -d "$oldDate" +%s
Otherwise bash sees the spaces inside the variable and tries to split it into multiple arguments.