I've got several different directories that contain different versions of some files. I want to count a symbol in all versions of the same file. Here is an example of the hierarchy.
directory
version1
1_file.txt
2_file.txt
...
version2
1_file.txt
2_file.txt
...
...
I've tried the following:
symbol=\>
for i in 1 2 3; do
grep -roh $symbol $i\_file.txt | wc -w;
done
grep -oh "$symbol" */{1..3}_file.txt | wc -w
. Also-r
switch is redundant, perhaps justgrep -roh "$symbol" . | wc -w
is sufficient for you. – jimmij Jul 9 '15 at 20:23grep
line – Jeff Schaller♦ Jul 9 '15 at 21:55