grep with regex question - Unix

This is a discussion on grep with regex question - Unix ; I am using grep inside a bash script and need to display all lines in a file without *_00*.mdl fm_00.mdl fm_89.mdl fm.mdl here I would only want to show the fm.mdl line I tried this : grep ".[^_0-90-9]." test.txt what ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: grep with regex question

  1. grep with regex question



    I am using grep inside a bash script and need to display all lines in
    a file without *_00*.mdl

    fm_00.mdl
    fm_89.mdl
    fm.mdl

    here I would only want to show the fm.mdl line



    I tried this :
    grep ".[^_0-90-9]." test.txt

    what is the proper syntax


  2. Re: grep with regex question

    2007-06-27, 22:50(-07), merrittr:
    >
    >
    > I am using grep inside a bash script and need to display all lines in
    > a file without *_00*.mdl
    >
    > fm_00.mdl
    > fm_89.mdl
    > fm.mdl
    >
    > here I would only want to show the fm.mdl line

    [...]

    grep -vE '_[0-9]{2}.*\.mdl$'

    > grep ".[^_0-90-9]." test.txt

    [...]

    a [...] operator always matches *one* character. Here that would
    be any character that wouldn't be any of _ or a decimal digit.

    --
    Stéphane

  3. Re: grep with regex question

    On Jun 28, 2:17 am, Stephane CHAZELAS wrote:
    > 2007-06-27, 22:50(-07), merrittr:
    >
    > > I am using grep inside a bash script and need to display all lines in
    > > a file without *_00*.mdl

    >
    > > fm_00.mdl
    > > fm_89.mdl
    > > fm.mdl

    >

    Thanks again
    Stephane that did the trick
    > > here I would only want to show the fm.mdl line



    >
    > [...]
    >
    > grep -vE '_[0-9]{2}.*\.mdl$'
    >
    > > grep ".[^_0-90-9]." test.txt

    >
    > [...]
    >
    > a [...] operator always matches *one* character. Here that would
    > be any character that wouldn't be any of _ or a decimal digit.
    >
    > --
    > Stéphane




  4. Re: grep with regex question

    merrittr wrote:
    >
    > I am using grep inside a bash script and need to display all lines in
    > a file without *_00*.mdl
    >
    > fm_00.mdl
    > fm_89.mdl
    > fm.mdl
    >
    > here I would only want to show the fm.mdl line
    >
    >
    >
    > I tried this :
    > grep ".[^_0-90-9]." test.txt
    >
    > what is the proper syntax
    >


    with std. grep:

    grep -v '_[0-9][0-9].*\.mdl$' test.txt

    --
    Michael Tosch @ hp : com

+ Reply to Thread