0

date -s "$(wget -qSO- --max-redirect=0 startpage.com 2>&1 | grep Date: | cut -d' ' -f5-8)"

Results in the following:

date: invalid date '13 May 2018 22:46:44'

date -s on AsusWRT requires something more like 2018-05-12 18:49:18 [this works]

This requires the month be turned to a number, and arranged as follows 2018-05-12 18:49:18; If this could be done exclusively in a single terminal command that would be phenomenal.

I've used 3 different versions to no avail, all available here on linuxquestions.org

Thank you deeply.

  • Here is the answer: datetext=$(curl -I '1.1.1.1/'; 2>/dev/null | grep "Date:" |sed 's/Date: [A-Z][a-z][a-z], //g'| sed 's/\r//') ; echo "Date Retrieved = $datetext" ; echo -n "Date set = " ; date -s "$datetext" -D'%d %b %Y %T %Z' – Boja May 14 '18 at 21:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.