1

When doing the grep recursive command to search a string within files:

grep -r "height:" *.txt
aaa.txt:height: 15
bbb.txt:height: 12
ccc.txt:height: 17

Can we safely assume that grep will always list files in the same order (i.e. alphanumeric) each time?

  • 1
    There are really two questions hiding in this; one around "-r" and one around globs. The duplicate is only answering the glob part. A full answer would also address the "-r" part, even if it's not what the OP was thinking about! – Stephen Harris Nov 23 '18 at 22:55
  • your command asks to search files ending in .txt and all files in directories ending in .txt. The order of the files (if no matching directories found), is determined by bash. bash expands the *.txt and passes the list to grep. Try echo *.txt. bash will do all the work, echo does next to nothing. – ctrl-alt-delor Nov 23 '18 at 23:43

0 Answers0