![]() ![]() If you properly used such pattern, the shell would pass all matching paths to grep (e.g. This feature is called "globstar" and one may need to explicitly enable it in a shell. In some shells you can use a glob that can match files in subdirectories. ![]() foo.c is a file of the type directory then -r will make grep descend into the directory but grep will read all files in the directory (it is still not aware of *.c you typed). If foo.c and bar.c are regular files then -r is irrelevant.It sees -r, iflag, bar.c, foo.c as its arguments. The above grep is not aware *.c was used.if there are two matching files foo.c and bar.c then your command will effectively be: grep -r iflag bar.c foo.c *.c is expanded to possibly multiple arguments: names of matching files in the current working directory. The first important thing that happens in Linux is the shell tries to expand *.c before it starts grep. it does not give you what you expected either. So let's assume for a while you run the command in Linux. You mentioned GnuWin, your OS is Windows, you probably used grep inside cmd.exe this brings some interesting nuances (we will get to them), but still your grep is designed to mimic GNU grep in Unix/Linux. To understand what happens, it's good to analyze first how this command behaves in Linux. ![]() Why your code does not work like you expectedĪnd you expected grep to recursively (because of -r) examine the current working directory and consider only files matching the pattern *.c. No answer posted so far has explained why your original code does not work like you expected. For what you want to do, using -include is the right way credit goes to other answers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |