【问题标题】:What is the x variable used for in the example commands below下面示例命令中使用的 x 变量是什么
【发布时间】:2014-03-06 19:24:10
【问题描述】:

在这篇帖子中:Count files and directories using shell script,DogBane 于 2012 年 12 月 5 日给出了这个回复:

FILECOUNT="$(find . -type f -maxdepth 1 -printf x | wc -c)"
DIRCOUNT="$(find . -type d -maxdepth 1 -printf x | wc -c)"

谁能告诉我 -printf 后面的 x 是什么意思或用途?

谢谢。

【问题讨论】:

  • 这是另一种的说法:FILECOUNT="$(find . -type f -maxdepth 1 | wc -l)" ...如果有帮助的话...

标签: bash command find


【解决方案1】:

-printf x 将为每个匹配项仅打印一个 x,没有换行符或其他任何内容(尤其是文件名)。

这些find 命令只为找到的每个文件(或目录)打印一个字符,然后计算字符数 (wc -c)。

【讨论】:

    猜你喜欢
    • 2020-07-15
    • 1970-01-01
    • 2017-06-11
    • 2020-10-29
    • 2022-09-23
    • 2013-07-29
    • 1970-01-01
    • 2013-05-17
    • 2012-03-02
    相关资源
    最近更新 更多