2015-02-23 113 views
0

我正在使用C API來管理藍牙通過bluetoothctl。它通過使用如下命令起作用:在控制檯和日誌文件上重定向stderr stdout

./BT_API connect $2 | bluetoothctl > /tmp/BT_TMP 

所有存儲在/ tmp/BT_TMP中但在屏幕上注意。我嘗試使用以下命令

./BT_API connect $2 | bluetoothctl 2>&1 /tmp/BT_TMP 

但現在全部顯示在屏幕上,但文件/ tmp/BT_TMP未創建。

回答

1

使用tee,將標準輸入重定向到兩個文件和stdout:

./BT_API connect $2 | bluetoothctl 2>&1 | tee /tmp/BT_TMP 
相關問題