I want to assign the "running time" of a script to a variable "realtime". So I tried as below:
realtime = `{ time (echo "mirror -Rv $LocalPath $LocalPath";echo "quit";)|lftp -u s1238262 FTPS://$RemoteHost ; } 2>&1 |grep "real"| awk '{print $2}'`
echo $realtime
But I got a error:
++ grep real
++ awk '{print $2}'
+ realtime = 0m2.403s
./test.sh: line 6: realtime: command not found
+ echo
I tried
realtime = `{ time pwd; } 2>&1 |grep real|awk '{print $2}'`
It did work. But the ftp script did not. Can anyone help me?
bash中的=
周围不能有空格。
result=`ls`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.