Created
October 29, 2023 22:56
-
-
Save disouzam/d87fc8978a9a6b15576c5803daa251aa to your computer and use it in GitHub Desktop.
Counting files with a given word using bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
file=./folder1/folder2/file-name-input.txt | |
outputfile=./folder1/folder2/file-name-output.txt | |
while IFS= read -r cmd; do | |
NUMBER_OF_FILES=$(grep --include=\*{ts,tsx} -rl './folder1' -e "$cmd" | wc -l) | |
printf 'Number of ocurrences: %s - Key: %s\n' "$NUMBER_OF_FILES" "$cmd" >> $outputfile | |
done < "$file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Important references that enabled me to reach the result above: