diff比较执行结果的方法

有时候要比较两个命令的结果有啥不同,最普通的方法就是将结果导到文件中,然后再diff

[oracle@qht115 ~]$ df -h > h.txt
[oracle@qht115 ~]$ df -m > m.txt
[oracle@qht115 ~]$ diff h.txt m.txt
1,5c1,5
< Filesystem            Size  Used Avail Use% Mounted on
< /dev/md2              5.0G  3.4G  1.4G  71% /
< tmpfs                 3.5G  1.6G  2.0G  45% /dev/shm
< /dev/md3              1.8T   38G  1.7T   3% /u01
< /dev/md0               99M   15M   79M  16% /boot
---
> Filesystem           1M-blocks      Used Available Use% Mounted on
> /dev/md2                  5042      3383      1403  71% /
> tmpfs                     3488      1540      1949  45% /dev/shm
> /dev/md3               1864589     38549   1731324   3% /u01
> /dev/md0                    99        15        79  16% /boot

有没有更加简便的方法呢?用下面管道的方法可以少产生一次文件

[oracle@qht115 ~]$ df -h | diff m.txt -
1,5c1,5
< Filesystem           1M-blocks      Used Available Use% Mounted on
< /dev/md2                  5042      3383      1403  71% /
< tmpfs                     3488      1540      1949  45% /dev/shm
< /dev/md3               1864589     38549   1731324   3% /u01
< /dev/md0                    99        15        79  16% /boot
---
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/md2              5.0G  3.4G  1.4G  71% /
> tmpfs                 3.5G  1.6G  2.0G  45% /dev/shm
> /dev/md3              1.8T   38G  1.7T   3% /u01
> /dev/md0               99M   15M   79M  16% /boot

有没有更加简便的方法?有的。这个方法和imp/imp命令的边导入/导出边压缩的写法差不多

[oracle@qht115 ~]$ diff <(df -h) <(df -m)
1,5c1,5
< Filesystem            Size  Used Avail Use% Mounted on
< /dev/md2              5.0G  3.4G  1.4G  71% /
< tmpfs                 3.5G  1.6G  2.0G  45% /dev/shm
< /dev/md3              1.8T   38G  1.7T   3% /u01
< /dev/md0               99M   15M   79M  16% /boot
---
> Filesystem           1M-blocks      Used Available Use% Mounted on
> /dev/md2                  5042      3383      1403  71% /
> tmpfs                     3488      1540      1949  45% /dev/shm
> /dev/md3               1864589     38549   1731324   3% /u01
> /dev/md0                    99        15        79  16% /boot

边导入/导出边压缩的写法:

exp l5m/l5m file=>(gzip>t.dmp.gz) tables=t 

imp l5m/l5m file=<(gunzip<t.dmp.gz) fromuser=l5m touser=l5m

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页