2012-08-01 6 views
3

내가 그것을 실행하는 배쉬 기능 걸리는 시간을보고 싶어요 작동합니다. 시간 bash는 기능에타이밍 강타는

function test-function() { 

    time (
     rsync -av ~/tmp/test-dir-start/ ~/tmp/test-dir-end/ 
     rsync -av ~/tmp/test-dir-start/ ~/tmp/test-dir-end-2/ 
     # etc... 
    ) 

} 

대체 있는가/더 나은 방법 : 약간의 연구를 수행 한 후, 나는 서브 쉘을 사용하는이 방법으로 왔어요?

업데이트 : time 호출을 함수에 포함하여 매번 time test-function을 수행하지 않고도 호출되도록하고 싶습니다. 나는 더 많은 명확해야합니다.

답변

7

당신은 명령을 사용할 수있는 서브 쉘이 아닌 그룹화 :

time { command1; command2; } 

업데이트 - 더 구체적인 예 :

test-function() { 

    time { 
    rsync -av ~/tmp/test-dir-start/ ~/tmp/test-dir-end/ 
    rsync -av ~/tmp/test-dir-start/ ~/tmp/test-dir-end-2/ 
    # etc... 
    } 
}