Summary: The results of a grep command on fixed text files SHOULD be extremely repeatable, but by the time they arrive in Mathematica they are not. When rapidly reading many shell commands, Mathematica's answers are wildly inconsistent.
The first line below discovers 9 small fixed text files. The second one repeatedly requests to find the word "fini" in the files and to print the line containing it. The Length function merely counts the number of words found.
gameNames=FileNames["game000*"];
Table[Length[ReadList["!grep fini "<>#,Word]]& /@ gameNames,6] //TableForm
This should produce a table of 6 lines where each column is all the same single consistent value. But instead it produces output like this:
4 4 4 4 4 4 0 0 0
0 4 0 0 0 0 0 0 0
0 0 4 4 4 0 4 0 0
0 0 0 4 0 0 0 0 0
0 4 4 0 0 0 4 4 0
4 0 0 0 0 4 4 0 0
Most columns here are erratic, which means the grep command is erratic, or the ReadList is. Which one? Why? What can be done about it?
In many executions of this code, the top left "4" is always the same (perhaps because it is the first in a rapid burst of executions), but most other entries seem capricious. The first 8 files each have a line in them containing 4 words, one of which is the word "fini" -- so the first 8 columns should be all 4's; the last file has no such line, so it should always be a column of 0's, which it has been in all runs observed.
Here is the data as obtained on a Unix Terminal (the absence of the 9th file in this list is what signals its lack of the word "fini" in it):
MacBook-Pro:BNS001-KPpairs me$ grep fini game000*
game0001.data:fini time limit expired
game0002.data:fini time limit expired
game0003.data:fini time limit expired
game0004.data:fini time limit expired
game0005.data:fini time limit expired
game0006.data:fini time limit expired
game0007.data:fini time limit expired
game0008.data:fini time limit expired
I posted a similar question several days ago, and therein I suggested that it might be an iCloud issue. The example given above, however, is running on files that live on a MacBook running Catalina below my /Users account not inside the Documents folder. No file or directory in the path has a little cloud symbol beside it in the Finder display. So I believe that possibility does not hold here.
grep fini game000*into your post as well? Might help figure out what's going on. – Carl Lange Sep 02 '20 at 13:11Equal @@@ Table[Length[ReadList["!ls", "Word"]], {5}, {5}]should always be a list ofTrue. Sometimes it is not. – Rohit Namjoshi Sep 02 '20 at 18:47lswithdir) – Gustavo Delfino Sep 02 '20 at 20:18Table[Import["!ls *000* | wc", "Text"], {15}, {7}] // TableForm Equal @@@ %works fine. It returns all True. Every time. So does this:Table[ StringLength[Import["!grep fini "<>#,"Text"]]&/@gameNames, 16]//TableForm Equal@@@Transpose[%]Go figure. – Carib John Sep 02 '20 at 21:26