Search code examples
linuxconsoledocco

How to send files from folder recursively to command in linux console?


I want to generate docs for coffee-script files. I want to use Docco.

When i use:

docco client/coffee/*

it throws error. I think because folders are in file list. When i use:

docco client/coffee/*.coffee

it cant' find some files, because i havent anithing in root folder.

How to give all *.coffee files recursievly to command in console?


Solution

  • There are several ways to do it

    $ find client/coffee/ -name '*.coffee' -exec docco {} +
    
    $ find client/coffee/ -name '*.coffee' | xargs docco
    

    However, note that the latter way does not work if there is space in file name, unless you use find -print0 with combination of xargs -0.

    Additionally, if you are using bash, you can use **/*.coffee with setting shopt -s globstar