From f6268760c5a2f421fd71f4d7aa8507109b77f3bf Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 17 Oct 2019 12:11:38 +0800 Subject: [PATCH 1/4] PRF @geekpi --- ...e and process files with find and xargs.md | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md b/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md index c06d43fae8..9aa020fa0f 100644 --- a/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md +++ b/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md @@ -1,50 +1,50 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (Command line quick tips: Locate and process files with find and xargs) [#]: via: (https://fedoramagazine.org/command-line-quick-tips-locate-and-process-files-with-find-and-xargs/) [#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) -命令行提示:使用 find 和 xargs 查找和处理文件 +命令行技巧:使用 find 和 xargs 查找和处理文件 ====== ![][1] -**find** 是日常工具箱中功能更强大,更灵活的命令行程序之一。它如它名字所暗示的:查找符合你指定条件的文件和目录。借助 **-exec** 或 **-delete** 之类的参数,你可以让它对找到的文件进行操作。 +`find` 是日常工具箱中功能强大、灵活的命令行程序之一。它如它名字所暗示的:查找符合你指定条件的文件和目录。借助 `-exec` 或 `-delete` 之类的参数,你可以让它对找到的文件进行操作。 -在[命令行提示][2]系列的这一期中,你将会看到 **find** 命令的介绍,并学习如何使用内置命令或使用 **xargs** 命令处理文件。 +在[命令行提示][2]系列的这一期中,你将会看到 `find` 命令的介绍,并学习如何使用内置命令或使用 `xargs` 命令处理文件。 ### 查找文件 -**find** 至少要加上查找的路径。例如,此命令将查找(并打印)系统上的每个文件: +`find` 至少要加上查找的路径。例如,此命令将查找(并打印)系统上的每个文件: ``` find / ``` -由于所有东西都是文件,因此你会看到大量的输出。这可能无法帮助你找到所需的内容。你可以更改路径参数缩小范围,但这实际上并没有比使用 **ls** 命令更好。因此,你需要考虑要查找的内容。 +由于一切皆文件,因此你会看到大量的输出。这可能无法帮助你找到所需的内容。你可以更改路径参数缩小范围,但这实际上并没有比使用 `ls` 命令更好。因此,你需要考虑要查找的内容。 -也许你想在家目录中查找所有 JPEG 文件。 **-name** 参数允许你将结果限制为与给定模式匹配的文件。 +也许你想在家目录中查找所有 JPEG 文件。 `-name` 参数允许你将结果限制为与给定模式匹配的文件。 ``` find ~ -name '*jpg' ``` -但是等等!如果其中一些扩展名是大写怎么办? **-iname** 类似于 **-name**,但不区分大小写: +但是等等!如果其中一些扩展名是大写怎么办? `-iname` 类似于 `-name`,但不区分大小写: ``` find ~ -iname '*jpg' ``` -很好!但是 8.3 命名方案出自 1985 年。某些图片的扩展名可能是 .jpeg。幸运的是,我们可以将模式使用“或”(**-o**)进行组合。括号会被转义,以便是 **find** 命令而不是 shell 程序尝试解释它们。 +很好!但是 8.3 命名方案出自 1985 年。某些图片的扩展名可能是 .jpeg。幸运的是,我们可以将模式使用“或”(`-o`)进行组合。括号需要转义,以便使 `find` 命令而不是 shell 程序尝试解释它们。 ``` find ~ \( -iname 'jpeg' -o -iname 'jpg' \) ``` -更进一步。如果你有一些以 jpg 结尾的目录怎么办? (为什么你将目录命名为 **bucketofjpg** 而不是 **pictures**。)我们可以加上 **-type** 参数来仅查找文件: +更进一步。如果你有一些以 `jpg` 结尾的目录怎么办?(我不懂你为什么将目录命名为 `bucketofjpg` 而不是 `pictures`?)我们可以加上 `-type` 参数来仅查找文件: ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f @@ -56,7 +56,7 @@ find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type d ``` -最近你拍摄了很多照片,因此使用 **-mtime**(修改时间)将范围缩小到最近一周修改过的文件。 **-7** 表示 7 天或更短时间内修改的所有文件。 +最近你拍摄了很多照片,因此使用 `-mtime`(修改时间)将范围缩小到最近一周修改过的文件。 `-7` 表示 7 天或更短时间内修改的所有文件。 ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 @@ -64,24 +64,19 @@ find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 ### 使用 xargs 进行操作 -**xargs** 命令从标准输入流中获取参数,并基于它们执行命令。继续使用上一节中的示例,假设你要将上周修改过的家目录中的所有 JPEG 文件复制到 U 盘,以便插到电子相册上。假设你已经将 U 盘挂载到 _/media/photo_display_。 +`xargs` 命令从标准输入流中获取参数,并基于它们执行命令。继续使用上一节中的示例,假设你要将上周修改过的家目录中的所有 JPEG 文件复制到 U 盘,以便插到电子相册上。假设你已经将 U 盘挂载到 `/media/photo_display`。 ``` find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 -print0 | xargs -0 cp -t /media/photo_display ``` -**find**命令与以前的版本略有不同。**-print0** 命令让输出有一些更改:它不使用换行符,而是添加了一个空字符。**xargs** 的 **-0**(零)选项可调整解析以达到预期效果。这很重要,不然对包含空格、引号或其他特殊字符的文件名执行操作可能无法按预期进行。对文件采取任何操作时,都应使用这些选项。 +这里的 `find` 命令与以前的版本略有不同。`-print0` 命令让输出有一些更改:它不使用换行符,而是添加了一个 `null` 字符。`xargs` 的 `-0`(零)选项可调整解析以达到预期效果。这很重要,不然对包含空格、引号或其他特殊字符的文件名执行操作可能无法按预期进行。对文件采取任何操作时,都应使用这些选项。 - -**cp**的 **-t** 参数很重要,因为 **cp** 通常要求目的地址在最后。你可以不使用 **xargs** 而使用 **find** 的 **-exec** 执行此操作,但是 **xargs** 的方式会更快,尤其是对于大量文件,因为它会单次调用 **cp**。 +`cp` 命令的 `-t` 参数很重要,因为 `cp` 通常要求目的地址在最后。你可以不使用 `xargs` 而使用 `find` 的 `-exec` 执行此操作,但是 `xargs` 的方式会更快,尤其是对于大量文件,因为它会单次调用 `cp`。 ### 了解更多 -这篇文章仅是 **find** 可以做的事情的表面。 **find** 支持基于权限、所有者、访问时间等的测试。它甚至可以将搜索路径中的文件与其他文件进行比较。将测试与布尔逻辑相结合,可以为你提供惊人的灵活性,以精确地找到你要查找的文件。使用内置命令或管道传递给 **xargs**,你可以快速处理大量文件。 - -_这篇文章的部分内容先前已发布在 [Opensource.com][3]。_ _ 照片由 [_Warren Wong_][4] 在 [Unsplash] [5] 上发表。_ - - +这篇文章仅仅是 `find` 可以做的事情的表面。 `find` 支持基于权限、所有者、访问时间等的测试。它甚至可以将搜索路径中的文件与其他文件进行比较。将测试与布尔逻辑相结合,可以为你提供惊人的灵活性,以精确地找到你要查找的文件。使用内置命令或管道传递给 `xargs`,你可以快速处理大量文件。 -------------------------------------------------------------------------------- @@ -90,7 +85,7 @@ via: https://fedoramagazine.org/command-line-quick-tips-locate-and-process-files 作者:[Ben Cotton][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2f2d737ca7fb66d04bcc0d2cd13159d51cdce160 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 17 Oct 2019 12:12:05 +0800 Subject: [PATCH 2/4] PUB @geekpi https://linux.cn/article-11469-1.html --- ...uick tips- Locate and process files with find and xargs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20191009 Command line quick tips- Locate and process files with find and xargs.md (98%) diff --git a/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md b/published/20191009 Command line quick tips- Locate and process files with find and xargs.md similarity index 98% rename from translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md rename to published/20191009 Command line quick tips- Locate and process files with find and xargs.md index 9aa020fa0f..038a61aaa6 100644 --- a/translated/tech/20191009 Command line quick tips- Locate and process files with find and xargs.md +++ b/published/20191009 Command line quick tips- Locate and process files with find and xargs.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11469-1.html) [#]: subject: (Command line quick tips: Locate and process files with find and xargs) [#]: via: (https://fedoramagazine.org/command-line-quick-tips-locate-and-process-files-with-find-and-xargs/) [#]: author: (Ben Cotton https://fedoramagazine.org/author/bcotton/) From eb0ffa885cc6c7c9fee137322c506ed7852b5d6e Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 17 Oct 2019 12:51:55 +0800 Subject: [PATCH 3/4] PRF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @singledo 还需要加强翻译质量,翻译完应该审读一下。另外,标点符号,请用中文的。 --- ... Zip File in Linux -Beginner-s Tutorial.md | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md b/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md index 2d8cb2f944..b1f79d4b27 100644 --- a/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md +++ b/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md @@ -1,48 +1,44 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) +[#]: translator: (singledo) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to Unzip a Zip File in Linux [Beginner’s Tutorial]) [#]: via: (https://itsfoss.com/unzip-linux/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) -如何在 linux 下解压 Zip 文件 +新手教程:如何在 Linux 下解压 Zip 文件 ====== -_**摘要: 将会向你展示如何在 ubuntu 和其他 linux 发行版本上解压文件 . 终端和图形界面的方法都会被讨论 **_ +> 本文将会向你展示如何在 Ubuntu 和其他 Linux 发行版本上解压文件。终端和图形界面的方法都会讨论。 -[Zip][1] 是一种最普通 , 最流行的方法来创建压缩存档文件 . 它也是一种古老的文件归档文件格式,创建于 1989 年 . 自从它被广泛的使用 , 你会经常遇见 zip 文件 . +[Zip][1] 是一种创建压缩存档文件的最普通、最流行的方法。它也是一种古老的文件归档文件格式,这种格式创建于 1989 年。由于它的广泛使用,你会经常遇见 zip 文件。 -在更早的一份教程 , 我展示了 [how to zip a folder in Linux][2] . 在这篇快速教程中 , 对于初学者我会展示如何在 linux 上解压文件 . +在更早的一份教程里,我介绍了[如何在 Linux 上用 zip 压缩一个文件夹][2]。在这篇面向初学者的快速教程中,我会介绍如何在 Linux 上解压文件。 -**先决条件: 检查你是否安装了 unzip** +先决条件:检查你是否安装了 `unzip`。 -为了解压 zip 归档文件 , 你必须解压安装包到你的系统 . 大多数现代的的 linux 发行版本提供解压 zip 文件的原生支持 . 校验它来避免以后出现坏的惊喜 . +为了解压 zip 归档文件,你必须在你的系统上安装了 unzip 软件包。大多数现代的的 Linux 发行版本提供了解压 zip 文件的支持,但是对这些 zip 文件进行校验以避免以后出现损坏总是没有坏处的。 -以 [Unbutu][3] 和 [Debian][4] 为基础的发行版本 , 你能够使用下面的命令来安装 unzip. 如果你已经安装了, 你会被告知已经被安装 . +在基于 [Unbutu][3] 和 [Debian][4] 的发行版上,你能够使用下面的命令来安装 `unzip`。如果你已经安装了,你会被告知已经被安装。 ``` sudo apt install unzip ``` -一旦你能够确认你的系统中安装了 unzip, 你就可以通过 unzip 来解压 zip 归档文件. - -你也能够使用命令行或者图形工具来达到目的, 我会向你展示两种方法. - - * [Unzip files in Linux terminal][5] - * [Unzip files in Ubuntu via GUI][6] +一旦你能够确认你的系统中安装了 `unzip`,你就可以通过 `unzip` 来解压 zip 归档文件。 +你也能够使用命令行或者图形工具来达到目的,我会向你展示两种方法: ### 使用命令行解压文件 -在 linux 下使用 unzip 命令是非常简单. 当你向解压 zip 文件, 用下面的命令: +在 Linux 下使用 `unzip` 命令是非常简单的。在你放 zip 文件的目录,用下面的命令: ``` unzip zipped_file.zip ``` -你可以给 zip 文件提供解压路径而不是当前所在路径 . 你会在终端输出中看到提取的文件: +你可以给 zip 文件提供解压路径而不是解压到当前所在路径。你会在终端输出中看到提取的文件: ``` unzip metallic-container.zip -d my_zip @@ -52,19 +48,19 @@ Archive: metallic-container.zip inflating: my_zip/License premium.txt ``` -上面的命令有一个小问题. 它会提取 zip 文件中所有的内容到现在的文件夹 . 你会在当前文件夹下留下一堆没有组织的文件, 这不是一件很好的事情. +上面的命令有一个小问题。它会提取 zip 文件中所有的内容到现在的文件夹。你会在当前文件夹下留下一堆没有组织的文件,这不是一件很好的事情。 #### 解压到文件夹下 -在 linux 命令行下, 对于把文件解压到一个文件夹下是一个好的做法. 这种方式下, 所有的提取文件都会被存储到你所指定的文件夹下. 如果文件夹不存在, 文件夹会被创建. +在 Linux 命令行下,对于把文件解压到一个文件夹下是一个好的做法。这种方式下,所有的提取文件都会被存储到你所指定的文件夹下。如果文件夹不存在,会创建该文件夹。 ``` unzip zipped_file.zip -d unzipped_directory ``` -现在 zipped_file.zip 中所有的内容都会被提取到 unzipped_directory 中. +现在 `zipped_file.zip` 中所有的内容都会被提取到 `unzipped_directory` 中。 -从我们讨论好的做法, 另一个注意点, 我们可以查看压缩文件中的内容而不用真实的解压 . +由于我们在讨论好的做法,这里有另一个注意点,我们可以查看压缩文件中的内容而不用实际解压。 #### 查看压缩文件中的内容而不解压压缩文件 @@ -72,7 +68,8 @@ unzip zipped_file.zip -d unzipped_directory unzip -l zipped_file.zip ``` -下面是命令的输出: +下面是该命令的输出: + ``` unzip -l metallic-container.zip Archive: metallic-container.zip @@ -85,20 +82,21 @@ Archive: metallic-container.zip 6578588 3 files ``` -在 linux 下, 这里还有些其他的 unzip 的用法, 你对在 linux 下使用解压文件有了足够的知识. +在 Linux 下,还有些 `unzip` 的其它用法,但我想你现在已经对在 Linux 下使用解压文件有了足够的了解。 ### 使用图形界面来解压文件 - 如果你使用桌面版 linux , 那你就不必总是使用终端. 在图形化的界面下,我们又要如何解压文件呢? 我使用 [GNOME desktop][7]. 和其他的桌面版 linux 发行版本相同 . - 打开文件管理器,然后跳转到压缩文件所在的文件夹下. 点击鼠标右键, 你会在弹出的窗口中看到 "extract here",选择它. +如果你使用桌面版 Linux,那你就不必总是使用终端。在图形化的界面下,我们又要如何解压文件呢? 我使用的是 [GNOME 桌面][7],不过其它桌面版 Linux 发行版也大致相同。 + +打开文件管理器,然后跳转到 zip 文件所在的文件夹下。在文件上点击鼠标右键,你会在弹出的窗口中看到 “提取到这里”,选择它。 ![Unzip File in Ubuntu][8] -与 unzip 命令不同, 提取选项会创建一个和压缩文件名相同的文件夹,并且把压缩文件中的所有内容存储到创建的文件夹下. 相对于 unzip 命令的默认行为是将压缩文件提取到当前所在的文件下,图形界面的解压对于我来说是一件非常好的事情. +与 `unzip` 命令不同,这个提取选项会创建一个和压缩文件名相同的文件夹(LCTT 译注:文件夹没有 `.zip` 扩展名),并且把压缩文件中的所有内容存储到创建的文件夹下。相对于 `unzip` 命令的默认行为是将压缩文件提取到当前所在的文件下,图形界面的解压对于我来说是一件非常好的事情。 -这里还有一个选项 "extract to", 你可以悬着特定的文件夹来存储提取文件. +这里还有一个选项“提取到……”,你可以选择特定的文件夹来存储提取的文件。 -你现在知道如何在 linux 解压文件. 你也许对学习有兴趣 [using 7zip in Linux][9] . +你现在知道如何在 Linux 解压文件了。你也许还对学习[在 Linux 下使用 7zip][9] 感兴趣? -------------------------------------------------------------------------------- @@ -107,7 +105,7 @@ via: https://itsfoss.com/unzip-linux/ 作者:[Abhishek Prakash][a] 选题:[lujun9972][b] 译者:[octopus](https://github.com/singledo) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3f085b436758635a4bdd60f11033e731dd74e1c6 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 17 Oct 2019 12:52:42 +0800 Subject: [PATCH 4/4] PUB @singledo https://linux.cn/article-11470-1.html --- ...1 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md (98%) diff --git a/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md b/published/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md similarity index 98% rename from translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md rename to published/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md index b1f79d4b27..a40d412a74 100644 --- a/translated/tech/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md +++ b/published/20191011 How to Unzip a Zip File in Linux -Beginner-s Tutorial.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (singledo) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11470-1.html) [#]: subject: (How to Unzip a Zip File in Linux [Beginner’s Tutorial]) [#]: via: (https://itsfoss.com/unzip-linux/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)