12/17/2023 0 Comments Grep recursive xls![]() ![]() We saw that in Linux your command results in *.c being expanded first, recursiveness starting later. Your grep in Windows is from the GnuWin project, it is designed to reasonably mimic the GNU grep you can find in Linux. It's good to know what parts of your command (in general: any command) are (or may be) expanded by the (or a) shell.Īnd now, finally, the nuances of Windows. Note -include=*.c is still a pattern your shell may expand if you want your code to be robust then you should escape or quote the asterisk. You want the other way around and one method to do it is with -include=*.c (the other is with globstar where the shell handles the recursiveness, but it can give you argument list too long error so it's better to let grep do this). In short, the reason your code doesn't work is *.c is expanded first (before grep runs), recursiveness starts later (when grep runs). You would need to quote or escape the pattern to protect it from the shell (see this question). There are tools that actually interpret such patterns in some circumstances (in fact grep -include is an example).Įven if grep was designed to interpret this *.c in your code as a pattern in the way you expected, in many cases your code wouldn't work. If it sees *.c where it expects a pathname then it will try to read a file named *.c. This cannot help you because grep itself is not designed to expand patterns in an argument it interprets as pathname.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |