Whitespace

watch 幾個命令的輸出不清楚

  • March 3, 2019

我正在我的伺服器上恢復數據庫備份,我需要觀察df -h和恢復實用程序的輸出db2pd -utilities。我試過這個:

watch -n 2 "db2pd -utilities && df -h

輸出(總結):

   Every 2.0s: db2pd -utilities && df -h    

 Database Member 0 -- Active -- Up 0 days 23:11:19 

 Utilities:
 Address        ID         Type        State      Invoker    Priority   

 0x000000E0     1          RESTORE      0          0          0          


 Progress:
 Address            ID         PhaseNum   CompletedWork                
 0x00003088         1          1          1073745920 bytes                          
 Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              39G  824M   36G   3% /
tmpfs                 253G   16K  253G   1% /dev/shm
/dev/sda2             194M   36M  149M  20% /boot
/dev/sda1             200M  264K  200M   1% /boot/efi
/dev/sda4              20G  215M   19G   2% /home
/dev/sda5              20G  1.4G   17G   8% /opt
/dev/sda9             166G  6.6G  151G   5% /tempWork
/dev/sda7             9.7G  152M  9.0G   2% /tmp
/dev/sda6              20G  227M   19G   2% /var

實際上輸出越來越長,我不得不刪除一些部分,它們結合在一起變得難以閱讀。我應該用什麼在它們之間騰出空間?

所需要的只是在原始命令之間添加一個 printf 語句: watch -n 2 "db2pd -utilities && printf '\n\n\n' && df -h"您可以使用它grep -v來隱藏各個實用程序的任何無關數據。

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