Page MenuHomePhabricator
Paste P11336

Shell script for count number of `it` statements
ActivePublic

Authored by Soham on May 29 2020, 2:01 PM.
Tags
None
Referenced Files
F31849995: raw.txt
Jun 1 2020, 11:22 AM
F31846966: raw.txt
May 29 2020, 2:01 PM
```
#!/bin/bash
count_it_recursive () {
shopt -s nullglob dotglob
for pathname in "$1"/*; do
if [ -d "$pathname" ]; then
count_it_recursive "$pathname"
else
case "$pathname" in
*.js)
grep -w -c -E "it(\.skip)?\(\s'.*'" "$pathname"
esac
fi
done
}
count_it_recursive $1
```
To trigger:
`sh count_it.sh PATH_TO_DIR`