linux中用shell时奇怪的字符串拼接和时间计算问题

2025-03-13 17:13:39
推荐回答(1个)
回答1:

testt=$(date +%Y-%m-%d)
date2="14/08/12"
test=20
testtt="${test}${date2}"
time1=$(date +%s -d "$testt" )
time2=$(date +%s -d "$testtt" )
time=$(($time1-$time2))
echo $time

改成引号,去掉括号!!