3 ms·
Thx for [3]. I usually just do wc -l *.c */*.c */*/*.c */*/*/*.c */*/*/*/*.c */*/*/*/*/*.c */*/*/*/*/*/*.c
by rweichler 5y ago
Thx for [3]. I usually just do
wc -l *.c */*.c */*/*.c */*/*/*.c */*/*/*/*.c */*/*/*/*/*.c */*/*/*/*/*/*.c
- marto1 5y agothis looks hilarious and I guess it works. nice one!
- parhamn 5y agoIn bash/zsh and many other shells '*/*.c' would be similar.
- kazinator 5y agoI don't think so. In Bash you can do this: bash$ shopt -s globstar Then you can use double star syntax like this: bash$ wc **/*.c The **/ will match any number of directory components, including zero; I think it's like *.c */*.c */*/*.c and so on, like what OP wrote. Somewhat sadly, the Glibc glob function does not have an equivalent GLOB_ option for this; it's just in Bash.
- rweichler 5y ago-bash: shopt: globstar: invalid shell option name
- kazinator 5y agoBash's NEWS file says that globstar was added between bash-3.2 and bash-4.0. In the git repo, there is a 2009-dated commit 3185942a5234e26ab13fa02f9c51d340cec514f8 where the material appears, as a snapshot import. Make sure you're using "shopt -s globstar" and not "shopt -o globstar".
- thangalin 5y agowc -l $(find . -type f -name "*.c")
- kazinator 5y agowc $(git ls-files '*.c') This avoids counting things like generated code that is not checked in (lex.yy.c, y.tab.c or what have you), and any local test code or other junk you have laying around in the tree.