2015-10-19 73 views
0

我們的項目中有一個bash腳本(https://github.com/prsolucoes/gonotin - run.sh),需要使用printf來執行浮點執行時間。如何使BSD printf命令忽略語言環境

問題是在osx上使用locale = pt_br的printf,因爲它使用「,」而不是「。」。和printf命令不知道en_us數字,如「123.45」,只有「123,45」。

我的問題是關於在printf上忽略語言環境或在printf命令上傳遞自定義語言環境。

任何人都可以幫助我嗎?

謝謝。

+1

您是否檢查[this](http://unix.stackexchange.com/questions/104096/locale-dependent-bash-script-how-to-properly-ensure-locale)? –

+1

'LANG = pt_br printf ...'? – Cyrus

回答

2

對命令預先賦予變量賦值將使用該變量作爲臨時環境變量運行。所以在你的情況下,像

LC_NUMERIC=C printf "> Execution time: %.6f seconds\n\n" $dur 

應該做的伎倆。

More info about LC_* environment variables

相關問題