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

Re: [nslu2-general] grep problem

Expand Messages
  • Thaths
    ... The problem has to do with how shell and grep interact in parsing their arguments. You need to somehow indicate that the command line flags are finished
    Message 1 of 4 , Oct 6, 2006
      On 10/6/06, bullfrog528 <yahoo@...> wrote:
      > I'm trying to search a file with lines containing 2 dashes.
      > cat file|grep --
      > complains because it thinks I'm trying to use an option of dash.

      > If anyone can give me a pointer please do.

      The problem has to do with how shell and grep interact in parsing
      their arguments. You need to somehow indicate that the command line
      flags are finished and to stop parsing for those. The following works
      for me:

      $ cat file | grep -- --

      The first '--' tells the shell/grep to stop parsing for command line
      flags. The second '--' is the string to grep to search for.

      Thaths
      --
      Homer: He has all the money in the world, but there's one thing he can't buy.
      Marge: What's that?
      Homer: (pause) A dinosaur.
      -- Homer J. Simpson
      Sudhakar Chandra Slacker Without Borders
    • bullfrog528
      Hi Thankyou for putting me out of my misery. google thought i was trying to exclude something when i put - in the search box and the word minus wasn t
      Message 2 of 4 , Oct 6, 2006
        Hi

        Thankyou for putting me out of my misery.

        google thought i was trying to exclude something when i put "-" in
        the search box and the word "minus" wasn't helping.

        Thanks again

        Jeremy (Bullfrog)


        --- In nslu2-general@yahoogroups.com, "Brian Zhou" <b88zhou@...>
        wrote:
        >
        > Definitely not slug specific. But it is actually quite easy, try:
        >
        > grep [-][-] file
        >
        > -Brian Zhou
        >
        > --- In nslu2-general@yahoogroups.com, "bullfrog528" <yahoo@> wrote:
        > >
        > > Hi
        > >
        > > Yes not really a slug specific problem, or perhaps it is.
        > >
        > > I'm trying to search a file with lines containing 2 dashes.
        > >
        > > cat file|grep --
        > >
        > > complains because it thinks I'm trying to use an option of dash.
        > >
        > > I've also tried
        > >
        > > cat file|grep "--"
        > >
        > > and
        > >
        > > cat file|grep -i "--"
        > >
        > > Just to see if specifying an option would have any effect.
        > >
        > > Googling shows plenty of examples of escaped characters (for
        other
        > > non minus sign characters) and using the minus sign to match wild
        > > cards but I can find nothing to help me here.
        > >
        > > If anyone can give me a pointer please do.
        > >
        > > Thanks
        > >
        > > Jeremy
        > >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.