Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?grep and brackets in textgrep: Ignoring GREP_OPTIONS to search case-sensitiveHow to Get FreeBSD Grep to recognize '-' option?How to find/grep what is between string1 and string2?What does a “*” at the start of a regular expression do?Recursive Grep with filename pattern specifiedquote files matched by grepGrepping on du -h for all the files that are larger than 1GBDoes grep --color default to =auto or =always?

Why did a young George Washington sign a document admitting to assassinating a French military officer?

Conveying the idea of " judge a book by its cover" by " juger un livre par sa couverture"

Modify real part and leaves imaginary part unchanged

Can you decide not to sneak into a room after seeing your roll?

Print the sequence

Can you be promoted and then fired for-cause? (Performance)

D&D Monsters and Copyright

Modern warfare theory in a medieval setting

Little Endian Number to String Conversion

AD823 current sense

Looking for PC graphics demo software from the early 90s called "Unreal"

Why didn't Kes send Voyager home?

chain with double bond or triple bond

5v home network

Finding the linear functions defining a polyhedron through integer data?

How long should a test wait to assume that the result remains fixed

Can I use I2C over 2m cables?

What is this plane with its thick cockpit?

A Society Built Around Theft?

About heavy-duty vehicle diagnostic port

Consecutive numbers that are Manhattan distance 3 apart

Manifolds with nonwhere vanishing closed one forms

What kind of tools would be used to carve bone?

Why is the intercept changing in a logistic regression when all predictors are standardized?



Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?


grep and brackets in textgrep: Ignoring GREP_OPTIONS to search case-sensitiveHow to Get FreeBSD Grep to recognize '-' option?How to find/grep what is between string1 and string2?What does a “*” at the start of a regular expression do?Recursive Grep with filename pattern specifiedquote files matched by grepGrepping on du -h for all the files that are larger than 1GBDoes grep --color default to =auto or =always?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









4

















The man page for grep reads




-i, --ignore-case



      Ignore case distinctions in both the PATTERN and the input files. 
      (-i is specified by POSIX.)


However, if I change case on a filename, it won't work.



$ touch WHATEVER
$ grep -i pattern whatever
grep: whatever: No such file or directory


Am I missing something?










share|improve this question




























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – terdon
    Apr 18 at 10:29






  • 8





    That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

    – Monty Harder
    Apr 18 at 14:54











  • @MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

    – grep
    Apr 18 at 15:11






  • 4





    @grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

    – Monty Harder
    Apr 18 at 17:39







  • 3





    I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

    – Criggie
    Apr 18 at 21:24

















4

















The man page for grep reads




-i, --ignore-case



      Ignore case distinctions in both the PATTERN and the input files. 
      (-i is specified by POSIX.)


However, if I change case on a filename, it won't work.



$ touch WHATEVER
$ grep -i pattern whatever
grep: whatever: No such file or directory


Am I missing something?










share|improve this question




























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – terdon
    Apr 18 at 10:29






  • 8





    That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

    – Monty Harder
    Apr 18 at 14:54











  • @MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

    – grep
    Apr 18 at 15:11






  • 4





    @grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

    – Monty Harder
    Apr 18 at 17:39







  • 3





    I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

    – Criggie
    Apr 18 at 21:24













4












4








4








The man page for grep reads




-i, --ignore-case



      Ignore case distinctions in both the PATTERN and the input files. 
      (-i is specified by POSIX.)


However, if I change case on a filename, it won't work.



$ touch WHATEVER
$ grep -i pattern whatever
grep: whatever: No such file or directory


Am I missing something?










share|improve this question
















The man page for grep reads




-i, --ignore-case



      Ignore case distinctions in both the PATTERN and the input files. 
      (-i is specified by POSIX.)


However, if I change case on a filename, it won't work.



$ touch WHATEVER
$ grep -i pattern whatever
grep: whatever: No such file or directory


Am I missing something?







grep documentation






share|improve this question















share|improve this question













share|improve this question




share|improve this question



share|improve this question








edited Apr 19 at 9:56









Kusalananda

167k20 gold badges325 silver badges521 bronze badges




167k20 gold badges325 silver badges521 bronze badges










asked Apr 17 at 23:13









grepgrep

485 bronze badges




485 bronze badges















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – terdon
    Apr 18 at 10:29






  • 8





    That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

    – Monty Harder
    Apr 18 at 14:54











  • @MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

    – grep
    Apr 18 at 15:11






  • 4





    @grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

    – Monty Harder
    Apr 18 at 17:39







  • 3





    I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

    – Criggie
    Apr 18 at 21:24

















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – terdon
    Apr 18 at 10:29






  • 8





    That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

    – Monty Harder
    Apr 18 at 14:54











  • @MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

    – grep
    Apr 18 at 15:11






  • 4





    @grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

    – Monty Harder
    Apr 18 at 17:39







  • 3





    I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

    – Criggie
    Apr 18 at 21:24
















Comments are not for extended discussion; this conversation has been moved to chat.

– terdon
Apr 18 at 10:29





Comments are not for extended discussion; this conversation has been moved to chat.

– terdon
Apr 18 at 10:29




8




8





That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

– Monty Harder
Apr 18 at 14:54





That switch is talking about the content of the file, not its name. The accepted answer does not at all address the problem shown here.

– Monty Harder
Apr 18 at 14:54













@MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

– grep
Apr 18 at 15:11





@MontyHarder The accepted answer implicitly confirms that the wording is confusing and supports that this is a non-issue in the new version.

– grep
Apr 18 at 15:11




4




4





@grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

– Monty Harder
Apr 18 at 17:39






@grep The problem you present is the non-existence of whatever, which the accepted answer does not in any way address. I am not aware of any version of grep that will look in WHATEVER when you ask it to look in whatever, under any circumstances. The accepted answer addresses grep -i PATTERN whatever, which is not grep -i pattern WHATEVER. Case-sensitivity of filenames is a *nix thing, not a grep thing.

– Monty Harder
Apr 18 at 17:39





3




3





I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

– Criggie
Apr 18 at 21:24





I would never have considered the -i parameter to apply to the filename, based on reading either man page line.

– Criggie
Apr 18 at 21:24










5 Answers
5






active

oldest

votes


















15


















That confusing snippet was changed in newer versions of GNU grep to:




-i, -ignore-case
Ignore case distinctions, so that characters that differ only in case match each other.




See this commit: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e1ca01be48cb64e5eaa6b5b29910e7eea1719f91



 .BR -i ", " -^-ignore-case
-Ignore case distinctions in both the
-.I PATTERN
-and the input files.
+Ignore case distinctions, so that characters that differ only in case
+match each other.



As to where the old formulation may originate, some programs like less(1) have a (mis)feature[1] where using an uppercase letter in a pattern will turn off case insensitivity for a particular search (override the -i flag). The author of that doc snippet probably assumed that many people expected that behavior, and instead of some direct caveat, preferred that non-committal sentence. FWIW, such a feature was never a part of ed(1), grep(1), vi(1), perl(1) etc. or of the regex(3) or pcre(3) APIs.



[1] that seems to have its origins in emacs, where it's the default; there you can turn it off by setting the (customizable) search-upper-case variable to nil.






share|improve this answer




























  • Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

    – grep
    Apr 17 at 23:57






  • 1





    I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

    – Stéphane Chazelas
    Apr 18 at 11:16






  • 1





    @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

    – mosvy
    Apr 18 at 12:39







  • 1





    You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

    – Stéphane Chazelas
    Apr 18 at 15:12







  • 1





    What does any of this have to do with mis-cased filenames?

    – Monty Harder
    Apr 18 at 17:47


















6


















Apparently I have a different manpage.



 -i, --ignore-case
Ignore case distinctions, so that characters that differ only in
case match each other.


In any case, it's not about the filenames.



It ignores case in the file (contents) but also in the pattern.



Test file:



___________
Hello World
^^^^^^^^^^^


Grep results (ignore case of file contents):



$ grep hello test.txt 

$ grep Hello test.txt
Hello World
$ grep -i HELLO test.txt
Hello World
$ grep -i hello test.txt
Hello World


Grep results (ignore case of pattern):



$ grep [a-Z] test.txt 
grep: Invalid range end
$ grep -i [a-Z] test.txt
Hello World
$ grep -i [A-z] test.txt
Hello World
$ grep [A-z] test.txt
___________
Hello World
^^^^^^^^^^^


As you can see the results can sometimes be a little unexpected.



Not sure if there is an example where this actually matters more.






share|improve this answer





















  • 1





    "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

    – grep
    Apr 17 at 23:41







  • 2





    In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

    – user41515
    Apr 17 at 23:48











  • less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

    – frostschutz
    Apr 18 at 10:01



















6



















"It ignores case in the file (contents) but also in the pattern",
this suggests (although it doesn't necessarily say it),
that it is possible to ignore case in the pattern, but not in the contents. 
I'd like to understand how this would work
(ignoring pattern, but not contents -- or the other way around).




Well, for example, it could be written
so that a pattern of “hello” would match “Hello” in the file,
but not vice versa. 
While this sounds hypothetical, it is the way spell-check works. 
If your dictionary contains “stack” and “exchange”,
and your document contains “Stack Exchange”,
spell-check will succeed without error. 
But if your dictionary contains “Unix” and your document contains “unix”,
that will be flagged as an error.






share|improve this answer

































    6


















    Using the -i flag ignores the case of the matches, not the case of the filenames. You created a file whose name is all uppercase, but you told grep to open a file whose name is lowercase, leading to the "file not found" error message. Linux filenames are case-sensitive.






    share|improve this answer

































      0


















      "in both the PATTERN and the input files" = "in the pattern and in the input files". The preposition "in" applies to both clauses joined by "both".



      If the authors had intended to ignore case distinctions in both the PATTERN and the input filenames, they would have said so.




      In comments, OP explains that the Question is incorrectly framed. In response to OP's actual difficulty: The first line of the description on the man page you cite is "grep searches the named input FILEs (...) for lines containing a match to the given PATTERN." That is, grep searches for matches to the contents of files not for matches to their names.



      Of course, OP's clarification makes the accepted answer nonresponsive to the hidden question.






      share|improve this answer




























      • That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

        – grep
        Apr 19 at 9:30











      • Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

        – grep
        Apr 19 at 9:31












      • @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

        – Eric Towers
        Apr 19 at 9:32












      • I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

        – grep
        Apr 19 at 9:34







      • 1





        @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

        – Eric Towers
        Apr 19 at 9:42












      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );














      draft saved

      draft discarded
















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513108%2fis-grep-documentation-about-ignoring-case-wrong-since-it-doesnt-ignore-case-in%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      15


















      That confusing snippet was changed in newer versions of GNU grep to:




      -i, -ignore-case
      Ignore case distinctions, so that characters that differ only in case match each other.




      See this commit: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e1ca01be48cb64e5eaa6b5b29910e7eea1719f91



       .BR -i ", " -^-ignore-case
      -Ignore case distinctions in both the
      -.I PATTERN
      -and the input files.
      +Ignore case distinctions, so that characters that differ only in case
      +match each other.



      As to where the old formulation may originate, some programs like less(1) have a (mis)feature[1] where using an uppercase letter in a pattern will turn off case insensitivity for a particular search (override the -i flag). The author of that doc snippet probably assumed that many people expected that behavior, and instead of some direct caveat, preferred that non-committal sentence. FWIW, such a feature was never a part of ed(1), grep(1), vi(1), perl(1) etc. or of the regex(3) or pcre(3) APIs.



      [1] that seems to have its origins in emacs, where it's the default; there you can turn it off by setting the (customizable) search-upper-case variable to nil.






      share|improve this answer




























      • Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

        – grep
        Apr 17 at 23:57






      • 1





        I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

        – Stéphane Chazelas
        Apr 18 at 11:16






      • 1





        @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

        – mosvy
        Apr 18 at 12:39







      • 1





        You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

        – Stéphane Chazelas
        Apr 18 at 15:12







      • 1





        What does any of this have to do with mis-cased filenames?

        – Monty Harder
        Apr 18 at 17:47















      15


















      That confusing snippet was changed in newer versions of GNU grep to:




      -i, -ignore-case
      Ignore case distinctions, so that characters that differ only in case match each other.




      See this commit: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e1ca01be48cb64e5eaa6b5b29910e7eea1719f91



       .BR -i ", " -^-ignore-case
      -Ignore case distinctions in both the
      -.I PATTERN
      -and the input files.
      +Ignore case distinctions, so that characters that differ only in case
      +match each other.



      As to where the old formulation may originate, some programs like less(1) have a (mis)feature[1] where using an uppercase letter in a pattern will turn off case insensitivity for a particular search (override the -i flag). The author of that doc snippet probably assumed that many people expected that behavior, and instead of some direct caveat, preferred that non-committal sentence. FWIW, such a feature was never a part of ed(1), grep(1), vi(1), perl(1) etc. or of the regex(3) or pcre(3) APIs.



      [1] that seems to have its origins in emacs, where it's the default; there you can turn it off by setting the (customizable) search-upper-case variable to nil.






      share|improve this answer




























      • Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

        – grep
        Apr 17 at 23:57






      • 1





        I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

        – Stéphane Chazelas
        Apr 18 at 11:16






      • 1





        @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

        – mosvy
        Apr 18 at 12:39







      • 1





        You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

        – Stéphane Chazelas
        Apr 18 at 15:12







      • 1





        What does any of this have to do with mis-cased filenames?

        – Monty Harder
        Apr 18 at 17:47













      15














      15










      15









      That confusing snippet was changed in newer versions of GNU grep to:




      -i, -ignore-case
      Ignore case distinctions, so that characters that differ only in case match each other.




      See this commit: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e1ca01be48cb64e5eaa6b5b29910e7eea1719f91



       .BR -i ", " -^-ignore-case
      -Ignore case distinctions in both the
      -.I PATTERN
      -and the input files.
      +Ignore case distinctions, so that characters that differ only in case
      +match each other.



      As to where the old formulation may originate, some programs like less(1) have a (mis)feature[1] where using an uppercase letter in a pattern will turn off case insensitivity for a particular search (override the -i flag). The author of that doc snippet probably assumed that many people expected that behavior, and instead of some direct caveat, preferred that non-committal sentence. FWIW, such a feature was never a part of ed(1), grep(1), vi(1), perl(1) etc. or of the regex(3) or pcre(3) APIs.



      [1] that seems to have its origins in emacs, where it's the default; there you can turn it off by setting the (customizable) search-upper-case variable to nil.






      share|improve this answer
















      That confusing snippet was changed in newer versions of GNU grep to:




      -i, -ignore-case
      Ignore case distinctions, so that characters that differ only in case match each other.




      See this commit: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e1ca01be48cb64e5eaa6b5b29910e7eea1719f91



       .BR -i ", " -^-ignore-case
      -Ignore case distinctions in both the
      -.I PATTERN
      -and the input files.
      +Ignore case distinctions, so that characters that differ only in case
      +match each other.



      As to where the old formulation may originate, some programs like less(1) have a (mis)feature[1] where using an uppercase letter in a pattern will turn off case insensitivity for a particular search (override the -i flag). The author of that doc snippet probably assumed that many people expected that behavior, and instead of some direct caveat, preferred that non-committal sentence. FWIW, such a feature was never a part of ed(1), grep(1), vi(1), perl(1) etc. or of the regex(3) or pcre(3) APIs.



      [1] that seems to have its origins in emacs, where it's the default; there you can turn it off by setting the (customizable) search-upper-case variable to nil.







      share|improve this answer















      share|improve this answer




      share|improve this answer



      share|improve this answer








      edited Apr 18 at 17:09

























      answered Apr 17 at 23:52









      mosvymosvy

      17.7k2 gold badges24 silver badges55 bronze badges




      17.7k2 gold badges24 silver badges55 bronze badges















      • Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

        – grep
        Apr 17 at 23:57






      • 1





        I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

        – Stéphane Chazelas
        Apr 18 at 11:16






      • 1





        @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

        – mosvy
        Apr 18 at 12:39







      • 1





        You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

        – Stéphane Chazelas
        Apr 18 at 15:12







      • 1





        What does any of this have to do with mis-cased filenames?

        – Monty Harder
        Apr 18 at 17:47

















      • Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

        – grep
        Apr 17 at 23:57






      • 1





        I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

        – Stéphane Chazelas
        Apr 18 at 11:16






      • 1





        @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

        – mosvy
        Apr 18 at 12:39







      • 1





        You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

        – Stéphane Chazelas
        Apr 18 at 15:12







      • 1





        What does any of this have to do with mis-cased filenames?

        – Monty Harder
        Apr 18 at 17:47
















      Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

      – grep
      Apr 17 at 23:57





      Do you mind opening that link in private mode finding that part of the doc? I just went through all ten occurrences of "ignore" and couldn't find that bit.

      – grep
      Apr 17 at 23:57




      1




      1





      I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

      – Stéphane Chazelas
      Apr 18 at 11:16





      I find the less behaviour very useful. I would never use uppercase characters in my search query if I intended the search to be case sensitive. It's a sensible default IMO

      – Stéphane Chazelas
      Apr 18 at 11:16




      1




      1





      @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

      – mosvy
      Apr 18 at 12:39






      @StéphaneChazelas Having to edit a mixed-case word that was copy-pasted is not nice, and that feature is non-symmetric -- what is the syntax to search in less -i for "hello" but not "Hello"? As to the interaction between case insensitive search, compatibility chars like and locales, there are many nasty problems (while there, don't forget the titlecasing (eg Lj, lj , LJ = U+01C7-U+01C9), another horrible contraption for a non-existing problem).

      – mosvy
      Apr 18 at 12:39





      1




      1





      You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

      – Stéphane Chazelas
      Apr 18 at 15:12






      You can get all those behaviours in less by entering -i and -I within less. The default is case-sensitive, -i is the default chosen by mandb, git, and IMO is useful. For a complete case insensitive (like for your copy-paste case), there's -I. vim has the smartcase option as an equivalent of less -i behaviour. GNU info and GNU emacs behave like less -i in this instance.

      – Stéphane Chazelas
      Apr 18 at 15:12





      1




      1





      What does any of this have to do with mis-cased filenames?

      – Monty Harder
      Apr 18 at 17:47





      What does any of this have to do with mis-cased filenames?

      – Monty Harder
      Apr 18 at 17:47













      6


















      Apparently I have a different manpage.



       -i, --ignore-case
      Ignore case distinctions, so that characters that differ only in
      case match each other.


      In any case, it's not about the filenames.



      It ignores case in the file (contents) but also in the pattern.



      Test file:



      ___________
      Hello World
      ^^^^^^^^^^^


      Grep results (ignore case of file contents):



      $ grep hello test.txt 

      $ grep Hello test.txt
      Hello World
      $ grep -i HELLO test.txt
      Hello World
      $ grep -i hello test.txt
      Hello World


      Grep results (ignore case of pattern):



      $ grep [a-Z] test.txt 
      grep: Invalid range end
      $ grep -i [a-Z] test.txt
      Hello World
      $ grep -i [A-z] test.txt
      Hello World
      $ grep [A-z] test.txt
      ___________
      Hello World
      ^^^^^^^^^^^


      As you can see the results can sometimes be a little unexpected.



      Not sure if there is an example where this actually matters more.






      share|improve this answer





















      • 1





        "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

        – grep
        Apr 17 at 23:41







      • 2





        In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

        – user41515
        Apr 17 at 23:48











      • less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

        – frostschutz
        Apr 18 at 10:01
















      6


















      Apparently I have a different manpage.



       -i, --ignore-case
      Ignore case distinctions, so that characters that differ only in
      case match each other.


      In any case, it's not about the filenames.



      It ignores case in the file (contents) but also in the pattern.



      Test file:



      ___________
      Hello World
      ^^^^^^^^^^^


      Grep results (ignore case of file contents):



      $ grep hello test.txt 

      $ grep Hello test.txt
      Hello World
      $ grep -i HELLO test.txt
      Hello World
      $ grep -i hello test.txt
      Hello World


      Grep results (ignore case of pattern):



      $ grep [a-Z] test.txt 
      grep: Invalid range end
      $ grep -i [a-Z] test.txt
      Hello World
      $ grep -i [A-z] test.txt
      Hello World
      $ grep [A-z] test.txt
      ___________
      Hello World
      ^^^^^^^^^^^


      As you can see the results can sometimes be a little unexpected.



      Not sure if there is an example where this actually matters more.






      share|improve this answer





















      • 1





        "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

        – grep
        Apr 17 at 23:41







      • 2





        In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

        – user41515
        Apr 17 at 23:48











      • less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

        – frostschutz
        Apr 18 at 10:01














      6














      6










      6









      Apparently I have a different manpage.



       -i, --ignore-case
      Ignore case distinctions, so that characters that differ only in
      case match each other.


      In any case, it's not about the filenames.



      It ignores case in the file (contents) but also in the pattern.



      Test file:



      ___________
      Hello World
      ^^^^^^^^^^^


      Grep results (ignore case of file contents):



      $ grep hello test.txt 

      $ grep Hello test.txt
      Hello World
      $ grep -i HELLO test.txt
      Hello World
      $ grep -i hello test.txt
      Hello World


      Grep results (ignore case of pattern):



      $ grep [a-Z] test.txt 
      grep: Invalid range end
      $ grep -i [a-Z] test.txt
      Hello World
      $ grep -i [A-z] test.txt
      Hello World
      $ grep [A-z] test.txt
      ___________
      Hello World
      ^^^^^^^^^^^


      As you can see the results can sometimes be a little unexpected.



      Not sure if there is an example where this actually matters more.






      share|improve this answer














      Apparently I have a different manpage.



       -i, --ignore-case
      Ignore case distinctions, so that characters that differ only in
      case match each other.


      In any case, it's not about the filenames.



      It ignores case in the file (contents) but also in the pattern.



      Test file:



      ___________
      Hello World
      ^^^^^^^^^^^


      Grep results (ignore case of file contents):



      $ grep hello test.txt 

      $ grep Hello test.txt
      Hello World
      $ grep -i HELLO test.txt
      Hello World
      $ grep -i hello test.txt
      Hello World


      Grep results (ignore case of pattern):



      $ grep [a-Z] test.txt 
      grep: Invalid range end
      $ grep -i [a-Z] test.txt
      Hello World
      $ grep -i [A-z] test.txt
      Hello World
      $ grep [A-z] test.txt
      ___________
      Hello World
      ^^^^^^^^^^^


      As you can see the results can sometimes be a little unexpected.



      Not sure if there is an example where this actually matters more.







      share|improve this answer













      share|improve this answer




      share|improve this answer



      share|improve this answer










      answered Apr 17 at 23:32









      frostschutzfrostschutz

      31.3k2 gold badges70 silver badges102 bronze badges




      31.3k2 gold badges70 silver badges102 bronze badges










      • 1





        "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

        – grep
        Apr 17 at 23:41







      • 2





        In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

        – user41515
        Apr 17 at 23:48











      • less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

        – frostschutz
        Apr 18 at 10:01













      • 1





        "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

        – grep
        Apr 17 at 23:41







      • 2





        In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

        – user41515
        Apr 17 at 23:48











      • less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

        – frostschutz
        Apr 18 at 10:01








      1




      1





      "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

      – grep
      Apr 17 at 23:41






      "It ignores case in the file (contents) but also in the pattern", this suggests (although it doesn't necessarily say it), that it is possible to ignore case in the pattern, but not in the contents. I'd like to understand how this would work (ignoring pattern, but not contents -- or the other way around).

      – grep
      Apr 17 at 23:41





      2




      2





      In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

      – user41515
      Apr 17 at 23:48





      In less, for example, there's a -i mode in which matching is case-insensitive if you only use lowercase letters in the pattern, but if there are any uppercase letters in the pattern, the whole thing is case-sensitive. That's like (sometimes) ignoring case in the contents but not the pattern.

      – user41515
      Apr 17 at 23:48













      less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

      – frostschutz
      Apr 18 at 10:01






      less is an interactive program quite unlike grep, not sure how it relates at all. interactive programs make usability choices, like nano where you can change case-sensitivity by hotkey. As for the manpage I think the old text actually explained it better, the new one does not make clear the pattern meaning itself changes too (even if [A-z] example is a bit constructed, the match result is completely different, so it should be in the manpage, but isn't anymore).

      – frostschutz
      Apr 18 at 10:01












      6



















      "It ignores case in the file (contents) but also in the pattern",
      this suggests (although it doesn't necessarily say it),
      that it is possible to ignore case in the pattern, but not in the contents. 
      I'd like to understand how this would work
      (ignoring pattern, but not contents -- or the other way around).




      Well, for example, it could be written
      so that a pattern of “hello” would match “Hello” in the file,
      but not vice versa. 
      While this sounds hypothetical, it is the way spell-check works. 
      If your dictionary contains “stack” and “exchange”,
      and your document contains “Stack Exchange”,
      spell-check will succeed without error. 
      But if your dictionary contains “Unix” and your document contains “unix”,
      that will be flagged as an error.






      share|improve this answer






























        6



















        "It ignores case in the file (contents) but also in the pattern",
        this suggests (although it doesn't necessarily say it),
        that it is possible to ignore case in the pattern, but not in the contents. 
        I'd like to understand how this would work
        (ignoring pattern, but not contents -- or the other way around).




        Well, for example, it could be written
        so that a pattern of “hello” would match “Hello” in the file,
        but not vice versa. 
        While this sounds hypothetical, it is the way spell-check works. 
        If your dictionary contains “stack” and “exchange”,
        and your document contains “Stack Exchange”,
        spell-check will succeed without error. 
        But if your dictionary contains “Unix” and your document contains “unix”,
        that will be flagged as an error.






        share|improve this answer




























          6














          6










          6










          "It ignores case in the file (contents) but also in the pattern",
          this suggests (although it doesn't necessarily say it),
          that it is possible to ignore case in the pattern, but not in the contents. 
          I'd like to understand how this would work
          (ignoring pattern, but not contents -- or the other way around).




          Well, for example, it could be written
          so that a pattern of “hello” would match “Hello” in the file,
          but not vice versa. 
          While this sounds hypothetical, it is the way spell-check works. 
          If your dictionary contains “stack” and “exchange”,
          and your document contains “Stack Exchange”,
          spell-check will succeed without error. 
          But if your dictionary contains “Unix” and your document contains “unix”,
          that will be flagged as an error.






          share|improve this answer















          "It ignores case in the file (contents) but also in the pattern",
          this suggests (although it doesn't necessarily say it),
          that it is possible to ignore case in the pattern, but not in the contents. 
          I'd like to understand how this would work
          (ignoring pattern, but not contents -- or the other way around).




          Well, for example, it could be written
          so that a pattern of “hello” would match “Hello” in the file,
          but not vice versa. 
          While this sounds hypothetical, it is the way spell-check works. 
          If your dictionary contains “stack” and “exchange”,
          and your document contains “Stack Exchange”,
          spell-check will succeed without error. 
          But if your dictionary contains “Unix” and your document contains “unix”,
          that will be flagged as an error.







          share|improve this answer













          share|improve this answer




          share|improve this answer



          share|improve this answer










          answered Apr 17 at 23:57









          G-ManG-Man

          15.4k9 gold badges44 silver badges86 bronze badges




          15.4k9 gold badges44 silver badges86 bronze badges
























              6


















              Using the -i flag ignores the case of the matches, not the case of the filenames. You created a file whose name is all uppercase, but you told grep to open a file whose name is lowercase, leading to the "file not found" error message. Linux filenames are case-sensitive.






              share|improve this answer






























                6


















                Using the -i flag ignores the case of the matches, not the case of the filenames. You created a file whose name is all uppercase, but you told grep to open a file whose name is lowercase, leading to the "file not found" error message. Linux filenames are case-sensitive.






                share|improve this answer




























                  6














                  6










                  6









                  Using the -i flag ignores the case of the matches, not the case of the filenames. You created a file whose name is all uppercase, but you told grep to open a file whose name is lowercase, leading to the "file not found" error message. Linux filenames are case-sensitive.






                  share|improve this answer














                  Using the -i flag ignores the case of the matches, not the case of the filenames. You created a file whose name is all uppercase, but you told grep to open a file whose name is lowercase, leading to the "file not found" error message. Linux filenames are case-sensitive.







                  share|improve this answer













                  share|improve this answer




                  share|improve this answer



                  share|improve this answer










                  answered Apr 18 at 11:27









                  stolenmomentstolenmoment

                  4642 silver badges4 bronze badges




                  4642 silver badges4 bronze badges
























                      0


















                      "in both the PATTERN and the input files" = "in the pattern and in the input files". The preposition "in" applies to both clauses joined by "both".



                      If the authors had intended to ignore case distinctions in both the PATTERN and the input filenames, they would have said so.




                      In comments, OP explains that the Question is incorrectly framed. In response to OP's actual difficulty: The first line of the description on the man page you cite is "grep searches the named input FILEs (...) for lines containing a match to the given PATTERN." That is, grep searches for matches to the contents of files not for matches to their names.



                      Of course, OP's clarification makes the accepted answer nonresponsive to the hidden question.






                      share|improve this answer




























                      • That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                        – grep
                        Apr 19 at 9:30











                      • Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                        – grep
                        Apr 19 at 9:31












                      • @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                        – Eric Towers
                        Apr 19 at 9:32












                      • I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                        – grep
                        Apr 19 at 9:34







                      • 1





                        @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                        – Eric Towers
                        Apr 19 at 9:42















                      0


















                      "in both the PATTERN and the input files" = "in the pattern and in the input files". The preposition "in" applies to both clauses joined by "both".



                      If the authors had intended to ignore case distinctions in both the PATTERN and the input filenames, they would have said so.




                      In comments, OP explains that the Question is incorrectly framed. In response to OP's actual difficulty: The first line of the description on the man page you cite is "grep searches the named input FILEs (...) for lines containing a match to the given PATTERN." That is, grep searches for matches to the contents of files not for matches to their names.



                      Of course, OP's clarification makes the accepted answer nonresponsive to the hidden question.






                      share|improve this answer




























                      • That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                        – grep
                        Apr 19 at 9:30











                      • Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                        – grep
                        Apr 19 at 9:31












                      • @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                        – Eric Towers
                        Apr 19 at 9:32












                      • I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                        – grep
                        Apr 19 at 9:34







                      • 1





                        @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                        – Eric Towers
                        Apr 19 at 9:42













                      0














                      0










                      0









                      "in both the PATTERN and the input files" = "in the pattern and in the input files". The preposition "in" applies to both clauses joined by "both".



                      If the authors had intended to ignore case distinctions in both the PATTERN and the input filenames, they would have said so.




                      In comments, OP explains that the Question is incorrectly framed. In response to OP's actual difficulty: The first line of the description on the man page you cite is "grep searches the named input FILEs (...) for lines containing a match to the given PATTERN." That is, grep searches for matches to the contents of files not for matches to their names.



                      Of course, OP's clarification makes the accepted answer nonresponsive to the hidden question.






                      share|improve this answer
















                      "in both the PATTERN and the input files" = "in the pattern and in the input files". The preposition "in" applies to both clauses joined by "both".



                      If the authors had intended to ignore case distinctions in both the PATTERN and the input filenames, they would have said so.




                      In comments, OP explains that the Question is incorrectly framed. In response to OP's actual difficulty: The first line of the description on the man page you cite is "grep searches the named input FILEs (...) for lines containing a match to the given PATTERN." That is, grep searches for matches to the contents of files not for matches to their names.



                      Of course, OP's clarification makes the accepted answer nonresponsive to the hidden question.







                      share|improve this answer















                      share|improve this answer




                      share|improve this answer



                      share|improve this answer








                      edited Apr 19 at 9:46

























                      answered Apr 19 at 9:14









                      Eric TowersEric Towers

                      1895 bronze badges




                      1895 bronze badges















                      • That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                        – grep
                        Apr 19 at 9:30











                      • Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                        – grep
                        Apr 19 at 9:31












                      • @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                        – Eric Towers
                        Apr 19 at 9:32












                      • I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                        – grep
                        Apr 19 at 9:34







                      • 1





                        @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                        – Eric Towers
                        Apr 19 at 9:42

















                      • That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                        – grep
                        Apr 19 at 9:30











                      • Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                        – grep
                        Apr 19 at 9:31












                      • @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                        – Eric Towers
                        Apr 19 at 9:32












                      • I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                        – grep
                        Apr 19 at 9:34







                      • 1





                        @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                        – Eric Towers
                        Apr 19 at 9:42
















                      That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                      – grep
                      Apr 19 at 9:30





                      That doesn't address my problem at all. I interpreted it as you suggest. I take issue with the meaning of "files". Why should it mean "file's contents"? I interpreted it as it being their names. Ultimately a file is neither its contents, nor their names.

                      – grep
                      Apr 19 at 9:30













                      Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                      – grep
                      Apr 19 at 9:31






                      Another thing that led to my confusion and led to the above-mentioned point, is that "ignoring case in the pattern, but not in the contents" is a concept that is extremely alien to me. In my mind if case is ignored in the pattern, then it is also ignored in the contents. Why then, reference contents if it is not possible to ignore case in the pattern, but not in the contents? I thought "OK, if this is being referenced, then surely it doesn't mean the file's contents, but the filenames".

                      – grep
                      Apr 19 at 9:31














                      @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                      – Eric Towers
                      Apr 19 at 9:32






                      @grep : You did not interpret it as I suggest. "in files" is not their filenames. Filenames are on the outside of files. For example, where in the file whatever is the string "whatever"?

                      – Eric Towers
                      Apr 19 at 9:32














                      I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                      – grep
                      Apr 19 at 9:34






                      I interpreted it as "in the pattern and in the input files". The thing is, you look at the word files here and think of its contents. I do not. What I meant with "I interpreted as you suggest" is that your rewording doesn't address my issue at all. It could have be worded as you suggest, and it would have led to my confusion anyway.

                      – grep
                      Apr 19 at 9:34





                      1




                      1





                      @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                      – Eric Towers
                      Apr 19 at 9:42





                      @grep : Either you read the first line of the description that directly informs you that grep searches the lines in files for matches or you didn't. Since apparently you did not read that line, you have no basis to complain that the documentation is incorrect.

                      – Eric Towers
                      Apr 19 at 9:42


















                      draft saved

                      draft discarded















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513108%2fis-grep-documentation-about-ignoring-case-wrong-since-it-doesnt-ignore-case-in%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

                      How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

                      Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü