I am trying to get the file time from the HTTP Header with the following command.
curl -sLI http://sgp-ping.vultr.com/vultr.com.100MB.bin | grep -i '^Last-Modified' | cut -c16- | date -f- '+%F %T' Under normal circumstances, it can return query results.
If the query fails due to network problems, it will return null.
I want to return the current system time when the query fails. So I use the shell operator "||", which is used as follows.
curl -sLI http://example.com/xxx.bin | grep -i '^Last-Modified' | cut -c16- | date -f- '+%F %T' || date '+%F %T' But it doesn't work as expected, what's wrong with it?
Any help, thanks in advance!
https://stackoverflow.com/questions/66593206/shell-operator-did-not-work-as-expected March 12, 2021 at 10:07AM
没有评论:
发表评论