[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)
以上就是[20170705]diff比较执行结果的内容.txt的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号