I have a shell script which checks every file in a folder for the word "Author"
counting the number of times Author appears per file and printing this out one line by file. The number has "hotel_$i"
as a prefix, where i is 1 at the top of the list and then increases as you go down the list. Here is my script:
#!/bin/bash
paste <(printf 'hotel_%d\n' {1..825}) \
<(find . -type f -exec bash -c 'grep -wo "Author" {} | wc -l' \; | sort -nr)
The problem is that I have 828 output lines (suggesting there are 828 files in my folder) when there are only 825 files in the folder. Here is my output:
hotel_1 2686
...(hotel_2 - hotel_824 output lines)
hotel_825 13
1
1
0
I assume that the 2 1's and the 0 are the "extra" files (perhaps not), why do they appear and how do I get rid of them? How is it possible for there to be more files in my folder than there actually appears?