Linux

linux/solaris + 標準輸出的操作

  • December 6, 2012

我在 linux/solaris 機器上執行以下行(所有輸出將從 application.bin 寫入 /tmp/Log )

./application.bin 1>>/tmp/Log

我們可以看到/tmp/Log文件的內容

more /tmp/Log

/etc/opt/OA/share/conf/OpC/mgmt_sv/ui/registration/C/opc_op /etc/opt/OA/share/conf/analysis/system_odbc.iniaaaa
/etc/opt/OA/share/conf/ovspmd.authaaaa
/etc/opt/OA/share/conf/ovwdb.authaaaa
/etc/opt/OA/share/conf/ovw.authaaaa 

我的問題:

我需要更改或添加語法:

  "1>>/tmp/Log" ? 

為了在每行之間添加空格,如下例所示

      /etc/opt/OA/share/conf/OpC/mgmt_sv/ui/registration/C/opc_op
 .
      /etc/opt/OA/share/conf/analysis/system_odbc.iniaaaa
 .
      /etc/opt/OA/share/conf/ovspmd.authaaaa
 .
      /etc/opt/OA/share/conf/ovwdb.authaaaa
 .
      /etc/opt/OA/share/conf/ovw.authaaaa 

備註 – 創建 /tmp/Log 後在每行之間添加空格的選項不相關

./application.bin | sed '$!G' >> /tmp/Log

引用自:https://unix.stackexchange.com/questions/57802