我想将脚本的“运行时间”分配给变量“实时”。所以我尝试如下:
realtime = `{ time (echo "mirror -Rv $LocalPath $LocalPath";echo "quit";)|lftp -u s1238262 FTPS://$RemoteHost ; } 2>&1 |grep "real"| awk '{print $2}'`
echo $realtime
但我得到一个错误:
++ grep real
++ awk '{print $2}'
+ realtime = 0m2.403s
./test.sh: line 6: realtime: command not found
+ echo
我试过了
realtime = `{ time pwd; } 2>&1 |grep real|awk '{print $2}'`
它确实奏效了。但是 ftp 脚本没有。谁能帮我?