Best way to divide in bash using pipes?

后端 未结 4 1603

I\'m just looking for an easy way to divide a number (or provide other math functions). Let\'s say I have the following command:

find . -name \'*.mp4\' | wc -l
<         


        
4条回答
  •  离开以前
    2021-02-02 14:21

    Depending on your bash version, you don't even need find for this simple task:

    shopt -s nullglob globstar
    files=( **/*.mp4 )
    dc -e "3 k ${#files[@]} 3 / p"
    

    This method will correctly handle the bizarre edgecase of filenames containing newlines.

提交回复
热议问题