开发者

script/command needed to list down all header files (.h files) in a directory (recursively)

开发者 https://www.devze.com 2023-03-26 03:49 出处:网络
given a base directory I would like to recursively list down all the header files under all directories below it

given a base directory I would like to recursively list down all the header files under all directories below it /*

And if possible, I would like the output to be something like:

headerfile:  <path 1>
             <path 2>
             ...
headerfile2: <path a>
             <path b> etc

Whats the best way of d开发者_运维百科oing it. I tried playing around with ls -R and grep, but i am fairly new to scripting.


find . -name "*.h"

for just the paths in the current dir and below. And if you can live with repeating the filename, and assuming I understood what you want as output, this is the more complex version...

find . -name "*.h" | while read i; do echo $(basename "$i") "$i"; done | sort
0

精彩评论

暂无评论...
验证码 换一张
取 消