echo -en "date: "
read sdate
mdate="date -d '${sdate} 00:00:00' +%s "
udate(){
$mdate
}
udate
出力
root@Xanarchy:/cnc# bash date
date: 01-01-2000
date: extra operand ‘+%s’
Try 'date --help' for more information.
ベストアンサー1
echo -en "date: "
read sdate
mdate=(date -d "${sdate} 00:00:00" +%s)
udate(){
"${mdate[@]}"
}
udate
文字列を使用すると、状況が不必要に複雑になります。配列の使用ははるかに簡単です。
01-01-2000
違法な入力ですdate
。あなたはする必要があります2000-01-01
。