How to convert any date to YYYYMMDDHHMMSS using unix shell script? -


how convert date yyyymmddhhmmss using unix shell script?
not specific date may date. how convert it?
example date format is: 20110101050603

thanks puspa

date = "15 jun 2015 10:10:10"; date -d"$date" +%y%m%d%h%m%s 

output :-

20150615101010 

more on dates
note works on gnu date.
have read that:

solaris version of date, unable support -d can resolve replacing sunfreeware.com version of date.

update:-
use ls command find files , use grep command files.

ls | grep "[0-9]{14}" 

grep command accepts regular expression.
won't validate file accurate. example, if file name 20151835101010, validate file. month , date both wrong.
suggestion write shell script identify valid file name , find oldest of them processing 1 one.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -