Execute a unix command

Hi,

Please suggest me to execute unix command.

Input : 2011-01-01 00:00:00

[YYYY-MM-DD HH24:MI:SS]

Required output : 20110101000000

YYYYMMDDHH24MISS

Regards
Akshu

Is your's gnu date ?

try whether the below command works or not

date -d "1 day ago" +%Y%m%d
1 Like

2011-01-01 00:00:00 is just a string..

Try

$ echo "2011-01-01 00:00:00" | sed 's/[ :-]//g'
20110101000000
2 Likes
echo '2011-01-01 00:00:00' | sed -n 's/[-| |:]//gp'
1 Like