Loading ...
Sorry, an error occurred while loading the content.
 

Re: how to configure grep to be case insenitive in filenames

Expand Messages
  • Yakov Lerner
    ... bash has nocaseglob option. Excerpt from man bash : nocaseglob If set, bash matches filenames in a case-insensitive fashion when performing pathname
    Message 1 of 12 , Apr 3 1:12 AM
      On 4/3/06, panshizhu@... <panshizhu@...> wrote:
      > "Edward Wong" <plwong@...> wrote on 2006.04.03 15:03:36:
      > > Ok I did a bit more testing.
      > >
      > > 1) I have a generated file named PDA.SS and PDA.S10
      > > 2) in .vimrc, set grepprg=grep\ -Hn
      > > 3) using cygwin as shell
      > >
      > > When I attempted to search a variable in PDA.SS and PDA.S10 I realized
      > > the followings:
      > >
      > > grep -i variable PDA.SS -> works
      > > grep -i variable pda.ss -> works
      > > grep -i variable *.SS -> works
      > > grep -i variable PDA.* -> works
      > > grep -i variable *.ss -> doesn't work
      > > grep -i variable pda.* -> doesn't work
      > > grep -i variable *.* -> works
      > >
      > > grep -i variable PDA.S10 -> works
      > > grep -i variable pda.s10 -> works
      > > grep -i variable *.*10 -> works
      > > grep -i variable *.s10 -> doesn't work
      > >
      > > So it seems like :grep doesn't work as expected when I search file
      > > patterns that contain combination of "*" and "letters with wrong
      > > capital values". Basically it DOESN'T "ignorecase" when "*" presents.
      > > However, I often needs to grep sth like *.s*, or pda.* for example.
      > >
      > > Any idea?
      >
      > Have you tried that in your BASH prompt? My result are below:
      >
      > pansz-pc:~$ grep fad test1.txt
      > adfadfaf
      > pansz-pc:~$ grep fad test1.TXT
      > adfadfaf
      > pansz-pc:~$ grep fad *.TXT
      > grep: *.TXT: No such file or directory
      > pansz-pc:~$ grep fad *.txt
      > test1.txt:adfadfaf
      > pansz-pc:~$

      bash has 'nocaseglob' option. Excerpt from 'man bash':
      nocaseglob
      If set, bash matches filenames in a case-insensitive
      fashion when performing pathname expansion (see Pathname
      Expansion above).
      tcsh has similar option

      Yakov
    • Edward Wong
      ... Yes I did...that s why i found the result weird and posted this mail. When I do this in shell: $ grep var *.s10 PDA.S10:02000B2177_varBcode
      Message 2 of 12 , Apr 4 3:35 AM
        > >
        > > Have you tried that in your BASH prompt? My result are below:

        Yes I did...that's why i found the result weird and posted this mail.
        When I do this in shell:

        $ grep var *.s10
        PDA.S10:02000B2177_varBcode
        PDA.S10:02000B21B1_varBcodeIndex
        PDA.S10:02000B2190_varBcodeName
        PDA.S10:02000B21B9_varBcodeNote
        PDA.S10:02000B21A9_varBcodeQty

        but when I do this in vim
        :grep var *.s10
        :!grep -Hn var *.s10 2>&1| tee C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/VIeDE.tmp
        (1 of 1): grep *.s10: No such file or directory

        > bash has 'nocaseglob' option. Excerpt from 'man bash':

        Yes...i already had:
        shopt -s nocaseglob
        in my .bashrc file.

        I'm thinking if the shell that vim prompts have ever sourced the
        .bashrc file since $HOME in vim is "d:\Programs\vim\vim70c" and $HOME
        in cygwin is "d:/cygwin/home/Administrator". Can it be the problem? I
        really dunno.... :(

        --
        Ed
      • Edward Wong
        ... Just tried setting $HOME to d:/cygwin/home/Administrator but :grep still returns No such file or directory
        Message 3 of 12 , Apr 4 3:40 AM
          > I'm thinking if the shell that vim prompts have ever sourced the
          > .bashrc file since $HOME in vim is "d:\Programs\vim\vim70c" and $HOME
          > in cygwin is "d:/cygwin/home/Administrator". Can it be the problem? I
          > really dunno.... :(

          Just tried setting $HOME to "d:/cygwin/home/Administrator" but :grep
          still returns 'No such file or directory'
        • David.Fishburn@sybase.com
          I had to use: grep var --include=*.s10 * You might want to try that way. HTH, Dave ... From: Edward Wong [plwong@gmail.com] Sent: 04/04/2006 03:40 AM To:
          Message 4 of 12 , Apr 4 4:18 AM
            I had to use:
            grep var --include=*.s10 *

            You might want to try that way.

            HTH,
            Dave




            ----- Original Message -----
            From: "Edward Wong" [plwong@...]
            Sent: 04/04/2006 03:40 AM
            To: "Yakov Lerner" <iler.ml@...>
            Cc: "panshizhu@..." <panshizhu@...>;vim@...
            Subject: Re: how to configure grep to be case insenitive in filenames

            > I'm thinking if the shell that vim prompts have ever sourced the
            > .bashrc file since $HOME in vim is "d:\Programs\vim\vim70c" and $HOME
            > in cygwin is "d:/cygwin/home/Administrator". Can it be the problem? I
            > really dunno.... :(

            Just tried setting $HOME to "d:/cygwin/home/Administrator" but :grep
            still returns 'No such file or directory'
          • Gary Johnson
            ... Well, that s the problem then. Bash only reads the ~/.bashrc file if it is an interactive shell, which shells spawned from vim are not. You might try
            Message 5 of 12 , Apr 4 11:57 AM
              On 2006-04-04, Edward Wong <plwong@...> wrote:
              > > >
              > > > Have you tried that in your BASH prompt? My result are below:
              >
              > Yes I did...that's why i found the result weird and posted this mail.
              > When I do this in shell:
              >
              > $ grep var *.s10
              > PDA.S10:02000B2177_varBcode
              > PDA.S10:02000B21B1_varBcodeIndex
              > PDA.S10:02000B2190_varBcodeName
              > PDA.S10:02000B21B9_varBcodeNote
              > PDA.S10:02000B21A9_varBcodeQty
              >
              > but when I do this in vim
              > :grep var *.s10
              > :!grep -Hn var *.s10 2>&1| tee C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/VIeDE.tmp
              > (1 of 1): grep *.s10: No such file or directory
              >
              > > bash has 'nocaseglob' option. Excerpt from 'man bash':
              >
              > Yes...i already had:
              > shopt -s nocaseglob
              > in my .bashrc file.

              Well, that's the problem then. Bash only reads the ~/.bashrc file
              if it is an interactive shell, which shells spawned from vim are
              not.

              You might try putting this in your ~/.vimrc:

              let $BASH_ENV="~/.bashrc"

              According to 'man bash',

              When bash is started non-interactively, to run a shell script, for
              example, it looks for the variable BASH_ENV in the environment, expands
              its value if it appears there, and uses the expanded value as the name
              of a file to read and execute. Bash behaves as if the following com-
              mand were executed:
              if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
              but the value of the PATH variable is not used to search for the file
              name.

              HTH,
              Gary

              --
              Gary Johnson | Agilent Technologies
              garyjohn@... | Wireless Division
              | Spokane, Washington, USA
            • Edward Wong
              Thanks Gary! That solves the problem. :)
              Message 6 of 12 , Apr 5 6:21 PM
                Thanks Gary! That solves the problem. :)

                On 4/5/06, Gary Johnson <garyjohn@...> wrote:
                > On 2006-04-04, Edward Wong <plwong@...> wrote:
                > > > >
                > > > > Have you tried that in your BASH prompt? My result are below:
                > >
                > > Yes I did...that's why i found the result weird and posted this mail.
                > > When I do this in shell:
                > >
                > > $ grep var *.s10
                > > PDA.S10:02000B2177_varBcode
                > > PDA.S10:02000B21B1_varBcodeIndex
                > > PDA.S10:02000B2190_varBcodeName
                > > PDA.S10:02000B21B9_varBcodeNote
                > > PDA.S10:02000B21A9_varBcodeQty
                > >
                > > but when I do this in vim
                > > :grep var *.s10
                > > :!grep -Hn var *.s10 2>&1| tee C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/VIeDE.tmp
                > > (1 of 1): grep *.s10: No such file or directory
                > >
                > > > bash has 'nocaseglob' option. Excerpt from 'man bash':
                > >
                > > Yes...i already had:
                > > shopt -s nocaseglob
                > > in my .bashrc file.
                >
                > Well, that's the problem then. Bash only reads the ~/.bashrc file
                > if it is an interactive shell, which shells spawned from vim are
                > not.
                >
                > You might try putting this in your ~/.vimrc:
                >
                > let $BASH_ENV="~/.bashrc"
                >
                > According to 'man bash',
                >
                > When bash is started non-interactively, to run a shell script, for
                > example, it looks for the variable BASH_ENV in the environment, expands
                > its value if it appears there, and uses the expanded value as the name
                > of a file to read and execute. Bash behaves as if the following com-
                > mand were executed:
                > if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
                > but the value of the PATH variable is not used to search for the file
                > name.
                >
                > HTH,
                > Gary
                >
                > --
                > Gary Johnson | Agilent Technologies
                > garyjohn@... | Wireless Division
                > | Spokane, Washington, USA
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.