start=`date +%s` && sh test.sh |sort|uniq -c && echo $[`date +%s` - $start]
shell 执行 sh test.sh |sort|uniq -c 命令并,统计执行命令花费的时间,单位为秒。。
可以使用 bash 的 time命令 如: time sh test.sh | sort |uniq -c
time 命令返回 real user sys时间
real:是该命令的总耗时,包括user和sys及io等待,时间片切换等待等等 user:是该命令在用户模式下的CPU耗时,也就是内核外的CPU耗时,不含IO等待这些时间 sys:是该命令在内核中的CPU耗时,不含IO,时间片切换耗时. 楼主需要的应该只是real这一项值