mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
ok
This commit is contained in:
parent
8f644a931a
commit
a1bc2e0470
@ -1,21 +1,20 @@
|
||||
hkurj translating
|
||||
How to Find Difference Between Two Directories Using Diff and Meld Tools
|
||||
怎么使用Diff和Meld工具得到2个目录之间的不同之处呢
|
||||
============================================================
|
||||
|
||||
In an earlier article, we reviewed [9 best file comparison and difference (Diff) tools for Linux][1] and in this article, we will describe how to find the difference between two directories in Linux.
|
||||
在一个之前的一篇文章,我们回顾了[ Linux 下的 9 个最好的文件比较工具][1]在这片文章,我们将会描述在 Linux 下这么找到2个目录之间的不同。
|
||||
|
||||
Normally, to [compare two files in Linux][2], we use the diff – a simple and original Unix command-line tool that shows you the difference between two computer files; compares files line by line and it is easy to use, comes with pre-installed on most if not all Linux distributions.
|
||||
一般,在Linux下比较2个文件,我们会使用diff (一个简单的原版的Unix命令行工具 )来显示2个计算机文件的不同;一行一行的去比较文件,而且很方便使用,几乎在全部的 Linux 发行版都预装了。
|
||||
|
||||
The question is how do we get the difference between two directories in Linux? Here, we want to know what files/subdirectories are common in the two directories, those that are present in one directory but not in the other.
|
||||
问题是在 Linux 下我们怎么才能比较2个目录的不同? 现在,我们想知道2个目录中那些文件/子目录是通用的,那些只存在一个目录。
|
||||
|
||||
The conventional syntax for running diff is as follows:
|
||||
运行diff常规的语法如下:
|
||||
|
||||
```
|
||||
$ diff [OPTION]… FILES
|
||||
$ diff options dir1 dir2
|
||||
```
|
||||
|
||||
By default, its output is ordered alphabetically by file/subdirectory name as shown in the screenshot below. In this command, the `-q` switch tells diff to report only when files differ.
|
||||
默认情况下,输出是按文件/子文件夹的文件名的字母排序的,如下面截图所示,在这命令“-q”开关是告诉diif只有在文件有差异时报告。
|
||||
|
||||
```
|
||||
$ diff -q directory-1/ directory-2/
|
||||
@ -24,17 +23,17 @@ $ diff -q directory-1/ directory-2/
|
||||
![Difference Between Two Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Difference-Between-Two-Directories.png)
|
||||
][3]
|
||||
|
||||
Difference Between Two Directories
|
||||
2个文件之间的差异
|
||||
|
||||
Again diff doesn’t go into the subdirectories, but we can use the `-r` switch to read the subdirectories as well like this.
|
||||
再次运行diff并不能进入子文件夹,但是我们可以使用'-r'开关和下面一样来读子文件夹。
|
||||
|
||||
```
|
||||
$ diff -qr directory-1/ directory-2/
|
||||
```
|
||||
|
||||
### Using Meld Visual Diff and Merge Tool
|
||||
###使用Meld可视化的比较和合并工具
|
||||
|
||||
There is a cool graphical option called meld (a visual diff and merge tool for the GNOME Desktop) for those who enjoy using the mouse, you can install it as follows.
|
||||
meld是一个很酷的图形化工具(一个GNOME桌面下的可视化的比较和合并工具)给那些喜欢使用鼠标的人,你们能根据下面来安装。
|
||||
|
||||
```
|
||||
$ sudo apt install meld [Debian/Ubuntu systems]
|
||||
@ -42,42 +41,36 @@ $ sudo yum install meld [RHEL/CentOS systems]
|
||||
$ sudo dnf install meld [Fedora 22+]
|
||||
```
|
||||
|
||||
Once you have installed it, search for “meld” in the Ubuntu Dash or Linux Mint Menu, in Activities Overview in Fedora or CentOS desktop and launch it.
|
||||
|
||||
You will see the Meld interface below, where you can choose file or directory comparison as well as version control view. Click on directory comparison and move to the next interface.
|
||||
一旦你安装了它之后,搜索“meld”在 Ubuntu Dash 或者 Linux Mint 菜单,也可以是Fedora或者CentOS桌面的Activities Overview,然后启动它。
|
||||
|
||||
你可以看到在下面看到Meld接口,你能和版本控制视图一样选择文件或者文件夹来比较。点击目录比较并移动到下个界面
|
||||
[
|
||||
![Meld Comparison Tool](http://www.tecmint.com/wp-content/uploads/2017/05/Meld-Comparison-Tool.png)
|
||||
][4]
|
||||
|
||||
Meld Comparison Tool
|
||||
|
||||
Select the directories you want to compare, note that you can add a third directory by checking the option “3-way Comparison”.
|
||||
Meld 比较工具
|
||||
|
||||
选择你想要比较的文件夹,注意你可以勾选“3-way Comparison”选项添加第3个文件夹。
|
||||
[
|
||||
![Select Comparison Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Select-Comparison-Directories.png)
|
||||
][5]
|
||||
|
||||
Select Comparison Directories
|
||||
|
||||
Once you selected the directories, click on “Compare”.
|
||||
选择比较的文件夹。
|
||||
|
||||
一旦你选择好了要比较的文件夹,点击 “Compare”。
|
||||
[
|
||||
![Listing Difference Between Directories](http://www.tecmint.com/wp-content/uploads/2017/05/Listing-Difference-Between-Directories.png)
|
||||
![Listing Difference Between +](http://www.tecmint.com/wp-content/uploads/2017/05/Listing-Difference-Between-Directories.png)
|
||||
][6]
|
||||
|
||||
Listing Difference Between Directories
|
||||
|
||||
In this article, we described how to find the difference between two directories in Linux. If you know any other commandline or gui way don’t forget to share your thoughts to this article via the comment section below.
|
||||
看结果出来了吧。
|
||||
|
||||
在这片文章我们描述了怎么在Linux下找到找出2个文件夹的不同。如果你知道其他的命令或者图形界面工具,不要忘记在下方评论分享你们的想法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
|
||||
|
||||
|
||||
Aaron Kili 是一个Linux和F.O.S.S爱好者,即将变成的Linux 系统管理员,Web开发者,目前是TecMint的内容创建者,他喜欢与电脑工作,并且非常相信分享知识。
|
||||
|
||||
-------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user