Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2004
    Posts
    30

    Unanswered: how to use pattern match with grep

    hi,

    i'm having problem like this.
    i wish to grep some keyword from certain files in one directory.

    let's say i have a lot of files in my directory with the name of file.1 file.2 file.3 ...... file.500
    i only wish to grep the keyword from file.20, file.21, file.23 .... file.50

    i tried the following command:
    ----------------------------
    grep 'keyword' file.[20-50]
    ----------------------------

    i used the command above and it returns no value.
    i found that [20-50] is not the appropriate way to specify file.
    anyone can guide me to this problem?

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Hi,

    The range specifier [min-max] applies to one character only. So [20-50] is not valid because there's no single character that represents '20' or '50'. [2-5] would be valid for the range file.2, file.3, file.4, file.5 but that's only part of the extension looked for. Thus the specifier '[2-5][0-9]' comes close but also returns the file.51, ...file.59 range so I would define the wanted range like this:
    Code:
    grep 'keyword' file.[2-4][0-9] file.50
    Regards

  3. #3
    Join Date
    Jul 2004
    Posts
    30
    Quote Originally Posted by Tyveleyn
    Hi,

    The range specifier [min-max] applies to one character only. So [20-50] is not valid because there's no single character that represents '20' or '50'. [2-5] would be valid for the range file.2, file.3, file.4, file.5 but that's only part of the extension looked for. Thus the specifier '[2-5][0-9]' comes close but also returns the file.51, ...file.59 range so I would define the wanted range like this:
    Code:
    grep 'keyword' file.[2-4][0-9] file.50
    Regards
    i see !!!!
    thanks for the help! have been figuring out for a long time!

    i got another answer too
    --------------------------------------
    grep 'pattern' file.@([234][0-9]|50)
    --------------------------------------
    well, it's doing the same thing anyway

    thanks !

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Code:
    file.{[2-4][0-9],50}
    works as well.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    Apr 2007
    Posts
    1
    pls i do i get simple shell script on how to monitor last transaction on the unix platform using seibel and genesy application and oracle db as the backend

  6. #6
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You may want to ask your question in the Oracle forum if you want to monitor Oracle transactions, or find a suitable forum for Siebel/Genesy (whatever the latter is).
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •