zoomzoom
Guru
- Joined
- Sep 6, 2015
- Messages
- 677
This is likely simple to fix , and am unsure when the change occurred, but after more than an hour yesterday trying different things while reviewing the
date
man page, I can't figure out what the correct parameter formatting should be, as I keep getting error output from:- This snippet is from a customized version of report.sh:
Code:# Problematic parameters: ## date -j -f "%Y-%b-%e_%H:%M:%S" "$scrubDate" "+%s" # Full snippet: statusOutput="$(zpool status "$pool")" if [ "$(echo "$statusOutput" | grep "scan" | awk '{print $2}')" = "scrub" ]; then scrubRepBytes="$(echo "$statusOutput" | grep "scan" | awk '{print $4}')" scrubErrors="$(echo "$statusOutput" | grep "scan" | awk '{print $10}')" # Convert time/datestamp format presented by zpool status, compare to current date, calculate scrub age: scrubDate="$(echo "$statusOutput" | grep "scan" | awk '{print $17"-"$14"-"$15"_"$16}')" scrubTS="$(date -j -f "%Y-%b-%e_%H:%M:%S" "$scrubDate" "+%s")" currentTS="$(date "+%s")" scrubAge=$((((currentTS - scrubTS) + 43200) / 86400)) scrubTime="$(echo "$statusOutput" | grep "scan" | awk '{print $8}')" fi
- Results with
date
errors:
Code:date: illegal option -- 1 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] date: illegal option -- 0 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] date: illegal option -- 0 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] date: illegal option -- 0 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] date: illegal option -- 0 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] date: illegal option -- 0 usage: date [-jnRu] [-d dst] [-r seconds|file] [-t west] [-v[+|-]val[ymwdHMS]] [-I[date | hours | minutes | seconds]] [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
Last edited: