Use find, wc, and sed to count lines

后端 未结 8 1517
攒了一身酷
攒了一身酷 2020-12-25 12:17

I was trying to use sed to count all the lines based on a particular extension.

find -name \'*.m\' -exec wc -l {} \\; | sed ...

I was tryi

8条回答
  •  温柔的废话
    2020-12-25 12:28

    On modern GNU platforms wc and find take -print0 and -files0-from parameters that can be combined into a command that count lines in files with total at the end. Example:

    find . -name '*.c' -type f -print0 | wc -l --files0-from=-
    

提交回复
热议问题