Entware Need help converting dates in shell script

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

Markster

Senior Member
I need some advice from coders here that have been using this version of Linux. I appreciate your help in advance.
Here is this example:

Run command "curl -s -I http://sbc.io/hosts/hosts | grep "[Ll]ast-[Mm]odified" | cut -c16-"
This retrieves Last-Modified time for a specific file. In this case it is a string Tue, 13 Apr 2021 14:04:19 GMT
I would like to convert this string to a format +%Y%m%d%H%M .

It is very easy on macOS/BSD since it does support date converting "from" to "new" format as in
date -jf '%A, %d %B %Y %H:%M:%S %Z' "${mydate}" '+%Y%m%d%H%M'

However on Asus Linux version I am not familiar how this can be converted. Any ideas or suggestions, I would appreciate it. Maybe someone already had solved it or do I need to include some entware lib to help with this work.
 

ColinTaylor

Part of the Furniture
If you have Entware you can install coreutils-date which contains a more versatile version of date.

Code:
# /opt/bin/date -d 'Tue, 13 Apr 2021 14:04:19 GMT' +%Y%m%d%H%M
202104131504
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top