From 5fc46b68eaebb81e4ed6f9ffaed8ba9708ff283d Mon Sep 17 00:00:00 2001 From: SamMa Date: Thu, 9 Sep 2021 09:17:11 +0800 Subject: [PATCH] Update 20210820 Check file status on Linux with the stat command.md --- ...e status on Linux with the stat command.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/translated/tech/20210820 Check file status on Linux with the stat command.md b/translated/tech/20210820 Check file status on Linux with the stat command.md index c89b1c0883..287613b4bc 100644 --- a/translated/tech/20210820 Check file status on Linux with the stat command.md +++ b/translated/tech/20210820 Check file status on Linux with the stat command.md @@ -3,28 +3,28 @@ [#]: author: "Seth Kenlon https://opensource.com/users/seth" [#]: collector: "lujun9972" [#]: translator: "New-World-2019" -[#]: reviewer: " " +[#]: reviewer: "turbokernel" [#]: publisher: " " [#]: url: " " 在 Linux 上使用 stat 命令查看文件状态 ====== -只需要一个 Linux 命令,你就可以获取到任何文件或文件系统的所有信息。 +获取到任何文件或文件系统的所有信息,仅需要一条 Linux 命令。 ![Hand putting a Linux file folder into a drawer][1] -命令 `stat` 被包含在 GNU `coreutils` 软件包里,它提供了关于文件和文件系统的各种元数据,包括文件大小、结点位置、访问权限和 SELinux 上下文以及创建和修改时间。通常情况下,你需要多个不同命令获取的信息,这一个命令就可以实现。 +在 GNU `coreutils` 软件包中包含 `stat` 命令,它提供了关于文件和文件系统包括文件大小、结点位置、访问权限和 SELinux 上下文以及创建和修改时间等各种元数据。通常情况下,你需要多个不同命令获取的信息,而这一个命令就可以实现。 ### 在 Linux 上安装 stat 命令 -在 Linux 系统中,可能早已安装了 `state` 命令,因为它是核心功能软件包的一部分,默认情况下,通常包含在 Linux 发行版里。 +在 Linux 系统中,可能已经预装了 `stat` 命令,因为它属于核心功能软件包,通常包含在 Linux 默认发行版里。 如果系统中没有安装 `stat` 命令,你可以使用包管理器安装 `coreutils` 软件包。 -另外,你可以 [ 使用源码编译 coreutils 包 ][2]。 +另外,你可以 [ 通过源码编译安装 coreutils 包 ][2]。 ### 获取文件状态 -运行 `stat` 命令可以获取指定文件或目录易于理解的输出。 +运行 `stat` 命令可以获取指定文件或目录易读的状态信息。 ``` @@ -40,7 +40,7 @@ Change: 2021-08-17 18:26:58.738332799 +1200 Birth: 2021-08-17 18:26:57.281330711 +1200 ``` -输出的信息很容易理解,但是包含了很多的信息,这里是 `stat` 所包含的项: +输出的信息易懂,但是包含了很多的信息,这里是 `stat` 所包含的项: * **File**: 文件名 * **Size**: 文件大小,以字节表示 @@ -58,7 +58,7 @@ Change: 2021-08-17 18:26:58.738332799 +1200 ### 精简输出 -对于非常了解输出或者想要使用其它工具(例如:[awk][3])解析输出的人,这里可以使用 `--terse`(短参数为 `-t`) 参数,实现没有标题或换行符的格式化输出。 +对于精通输出或者想要使用其它工具(例如:[awk][3])解析输出的人,这里可以使用 `--terse`(短参数为 `-t`) 参数,实现没有标题或换行符的格式化输出。 ``` @@ -66,9 +66,9 @@ $ stat --terse planets.xml planets.xml 325 8 81b4 100977 100 fd03 140217 1 0 0 1629181617 1629181618 1629181618 1629181617 4096 unconfined_u:object_r:user_home_t:s0 ``` -### 选择自己的格式 +### 自定义格式 -你可以使用 `--printf` 参数以及与 [printf][4] 类似的语法定义自己的输出格式。`stat` 的每一个属性都有一个格式序列(`%C` 表示 SELinux 上下文,`%n` 表示文件名等等),所以,你可以选择你想要的输出格式。 +你可以使用 `--printf` 参数以及与 [printf][4] 类似的语法定义自己的输出格式。`stat` 的每一个属性都有一个格式序列(`%C` 表示 SELinux 上下文,`%n` 表示文件名等等),所以,你可以定义输出格式。 ``` @@ -97,7 +97,7 @@ Modified: 2021-08-17 18:26:58.738332799 +1200 ### 文件信息 -如果你曾经尝试解析过 `ls -l` 的输出,那么,你会很喜欢 `stat` 命令的灵活性。你并不是每次都需要 `stat` 提供的所有信息,但是,当你需要其中一些或全部的时候它是非常有用的。不管你是读取默认输出,还是你自己创建的查询输出,`stat` 命令都可以让你访问想要的数据。 +如果你曾尝试解析过 `ls -l` 的输出,那么,你会很喜欢 `stat` 命令的灵活性。你并不是每次都需要 `stat` 提供的所有信息,但是,当你需要其中一些或全部的时候它是非常有用的。不管你是读取默认输出,还是你自己创建的查询输出,`stat` 命令都可以查看所需的数据。 -------------------------------------------------------------------------------- @@ -106,7 +106,7 @@ via: https://opensource.com/article/21/8/linux-stat-file-status 作者:[Seth Kenlon][a] 选题:[lujun9972][b] 译者:[New-World-2019](https://github.com/New-World-2019) -校对:[校对者ID](https://github.com/校对者ID) +校对:[turbokernel](https://github.com/turbokernel) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -115,4 +115,4 @@ via: https://opensource.com/article/21/8/linux-stat-file-status [1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) [2]: https://www.gnu.org/software/coreutils/ [3]: https://opensource.com/article/20/9/awk-ebook -[4]: https://opensource.com/article/20/8/printf \ No newline at end of file +[4]: https://opensource.com/article/20/8/printf