Use find, wc, and sed to count lines

后端 未结 8 1534
攒了一身酷
攒了一身酷 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:27

    Hm, solution with cat may be problematic if you have many files, especially big ones.

    Second solution doesn't give total, just lines per file, as I tested.

    I'll prefer something like this:

    find . -name '*.m' | xargs wc -l | tail -1
    

    This will do the job fast, no matter how many and how big files you have.

提交回复
热议问题