Announcement

Collapse
No announcement yet.

Help with unix commands

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with unix commands

    I'm trying to use sed, and it asks me to print all lines where b-days are in November or December. The way the input file is set up,

    sed -n '/^[^:]*:[^:]*:[^:]*:11/p' databook

    gives me the b-days in november, i just don't know how to make it do an "or" to get both. any ideas?
    "Mal nommer les choses, c'est accroître le malheur du monde" - Camus (thanks Davout)

    "I thought you must be dead ..." he said simply. "So did I for a while," said Ford, "and then I decided I was a lemon for a couple of weeks. A kept myself amused all that time jumping in and out of a gin and tonic."

  • #2
    I dunno how to do this portably, but in GNU sed you can use \| to match "either", like so:

    /^[^:]*:[^:]*:[^:]*:\(11\)\|\(12\)/p
    This is Shireroth, and Giant Squid will brutally murder me if I ever remove this link from my signature | In the end it won't be love that saves us, it will be mathematics | So many people have this concept of God the Avenger. I see God as the ultimate sense of humor -- SlowwHand

    Comment


    • #3
      Thankyou for reminding me why I never have used Linux...
      Speaking of Erith:

      "It's not twinned with anywhere, but it does have a suicide pact with Dagenham" - Linda Smith

      Comment


      • #4
        Just because you're not l33t enough...
        "Paul Hanson, you should give Gibraltar back to the Spanish" - Paiktis, dramatically over-estimating my influence in diplomatic circles.

        Eyewerks - you know you want to visit. No really, you do. Go on, click me.

        Comment


        • #5
          Originally posted by Provost Harrison
          Thankyou for reminding me why I never have used Linux...
          That's just a regular expression. Not more complicated than most of the biochem stuff.
          (\__/) 07/07/1937 - Never forget
          (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
          (")_(") "Starting the fire from within."

          Comment


          • #6
            paul hanson
            provost harrison

            both with eu markings...

            confusing.
            B♭3

            Comment


            • #7
              You think that's bad? We both spend a lot of time in the same city as well.
              "Paul Hanson, you should give Gibraltar back to the Spanish" - Paiktis, dramatically over-estimating my influence in diplomatic circles.

              Eyewerks - you know you want to visit. No really, you do. Go on, click me.

              Comment


              • #8
                God I'm so glad I'm back to WinXP
                "I work in IT so I'd be buggered without a computer" - Words of wisdom from Provost Harrison
                "You can be wrong AND jewish" - Wiglaf :love:

                Comment


                • #9
                  thanks
                  "Mal nommer les choses, c'est accroître le malheur du monde" - Camus (thanks Davout)

                  "I thought you must be dead ..." he said simply. "So did I for a while," said Ford, "and then I decided I was a lemon for a couple of weeks. A kept myself amused all that time jumping in and out of a gin and tonic."

                  Comment


                  • #10
                    Originally posted by Whaleboy
                    God I'm so glad I'm back to WinXP
                    For what? You don't need to know regex to use *nix.
                    (\__/) 07/07/1937 - Never forget
                    (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
                    (")_(") "Starting the fire from within."

                    Comment


                    • #11
                      Ah, of course, Doing it this way you don't need GNU extensions, AFAICT:

                      /^[^:]*:[^:]*:[^:]*:1[12]/p

                      Every time I use nonstandard extensions (such as the stuff GNU has added to so many *nix tools) anywhere I hear a little BSD daemon shouting at me about hypocrisy...
                      This is Shireroth, and Giant Squid will brutally murder me if I ever remove this link from my signature | In the end it won't be love that saves us, it will be mathematics | So many people have this concept of God the Avenger. I see God as the ultimate sense of humor -- SlowwHand

                      Comment


                      • #12
                        Out of curiosity, would this also work?

                        /^(.*?{3}1[12]/p

                        SP
                        Last edited by Fve Crathva; November 11, 2003, 06:18.
                        I got the Jete from C.C. Sabathia. : Jon Miller

                        Comment


                        • #13
                          Originally posted by Paul Hanson
                          Just because you're not l33t enough...
                          That is true, I am always on time
                          Speaking of Erith:

                          "It's not twinned with anywhere, but it does have a suicide pact with Dagenham" - Linda Smith

                          Comment


                          • #14
                            Originally posted by Paul Hanson
                            You think that's bad? We both spend a lot of time in the same city as well.
                            Except you spend your weekdays in Hull working (well, uni) and home in Lincolnshire on the weekends, whereas I spend my weekdays in Lincolnshire working and my weekends at home in Hull
                            Speaking of Erith:

                            "It's not twinned with anywhere, but it does have a suicide pact with Dagenham" - Linda Smith

                            Comment


                            • #15
                              Well, I'm actually spending more time in Hull this year. Not because I've developed an affinity for the place, but because my family drive me nuts.
                              "Paul Hanson, you should give Gibraltar back to the Spanish" - Paiktis, dramatically over-estimating my influence in diplomatic circles.

                              Eyewerks - you know you want to visit. No really, you do. Go on, click me.

                              Comment

                              Working...