Why using dirname in find command gives dots for each match?

前端 未结 7 1484
清酒与你
清酒与你 2021-02-01 15:16

I\'m using find for a task and I noticed that when I do something like this:

find `pwd` -name \"file.ext\" -exec echo $(dirname {}) \\;

it will

7条回答
  •  庸人自扰
    2021-02-01 15:29

    you do not have to call dirname() for each file found. with GNU find, you can use -printf and its faster this way

    find /path -type f -iname "*.ext" -printf "%h\n"
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题