[20170705]diff比較執行結果的內容.txt,20170705diff

來源:互聯網
上載者:User

[20170705]diff比較執行結果的內容.txt,20170705diff

[20170705]diff比較執行結果的內容.txt

--//有時候需要比較2個命令輸出的結果進行比較,比較笨的方法如下,例子:

$  lsnrctl status LISTENER_SCAN2 > /tmp/b2.txt
$  lsnrctl status LISTENER_SCAN3 > /tmp/b3.txt
$  diff -Nur /tmp/b2.txt /tmp/b3.txt

--//很明顯這樣要產生2個檔案,然後比較,實際上利用shell可以很簡單的實現.

$  lsnrctl status LISTENER_SCAN3 | diff /tmp/2.txt -
--//這樣減少1個檔案的產生,可以再減少檔案產生嗎?

$  diff <(lsnrctl status LISTENER_SCAN2) <(lsnrctl status LISTENER_SCAN3)

--//如何理解呢?
$  echo  <(lsnrctl status LISTENER_SCAN2) <(lsnrctl status LISTENER_SCAN3)
/dev/fd/63 /dev/fd/62
--//實際上62,63就是開啟的檔案控制代碼.當然執行完馬上關閉.

$  ls -l /dev/fd
lrwxrwxrwx 1 root root 13 2014-12-11 02:24:57 /dev/fd -> /proc/self/fd

$  ls -l /dev/fd/
total 0
lrwx------ 1 grid oinstall 64 2017-07-05 16:16:07 0 -> /dev/pts/4
lrwx------ 1 grid oinstall 64 2017-07-05 16:16:07 1 -> /dev/pts/4
lrwx------ 1 grid oinstall 64 2017-07-05 16:16:07 2 -> /dev/pts/4
lr-x------ 1 grid oinstall 64 2017-07-05 16:16:07 3 -> /proc/101318/fd

--//寫一個簡單的shell指令碼就很好理解了(注意這種寫法不是很嚴謹):
--//我直接讀取控制代碼63,62的內容.

$  cat a.sh
#! /bin/bash
echo  <(lsnrctl status LISTENER_SCAN2) <(lsnrctl status LISTENER_SCAN3)
diff /dev/fd/63 /dev/fd/62

$  . a.sh
/dev/fd/63 /dev/fd/62
6c6
< Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))
---
> Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))
9c9
< Alias                     LISTENER_SCAN2
---
> Alias                     LISTENER_SCAN3
11,12c11,12
< Start Date                30-JUN-2017 12:00:03
< Uptime                    5 days 4 hr. 18 min. 37 sec
---
> Start Date                30-JUN-2017 12:00:58
> Uptime                    5 days 4 hr. 17 min. 43 sec
17c17
< Listener Log File         /u01/app/11.2.0.4/grid/network/log/listener_scan2.log
---
> Listener Log File         /u01/app/11.2.0.4/grid/network/log/listener_scan3.log
19,20c19,20
<   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN2)))
<   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.109)(PORT=1521)))
---
>   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN3)))
>   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.107)(PORT=1521)))

--//想到這裡,我終於理解exp/imp on the fly.例子:

$ exp scott/book file=>(gzip >t.dmp.gz) tables=emp
$ imp scott/book full=y  file=<(gunzip <t.dmp.gz)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.