euglug.org

[작성자:] admin

  • Resolved: [Eug-lug] Source Code Processing



    Allen BrownThu May 5 21:26:12 PDT 2005

    On Thu, 5 May 2005, Jason Van Cleve wrote:
    > Quoth Bob Miller, on Thu, 5 May 2005 18:11:06 -0700:
    > 
    > > No, sed is precise with regard to newlines. (-: I was wondering if
    > 
    > The man page isn't very.  It doesn't mention "$" wrt regex's, just "\n":
    
    >From `man 7 regex`:
           An atom is a regular expression enclosed  in  `()'  (matching  a
           match  for the regular expression), an empty set of `()' (match-
           ing the null string)(!), a bracket expression (see  below),  `.'
           (matching  any  single character), `^' (matching the null string
           at the beginning of a line), `$' (matching the  null  string  at
           the  end  of  a  line),  a `\' followed by one of the characters
           `^.[$()|*+?{\' (matching that character  taken  as  an  ordinary
           character),  a `\' followed by any other character(!)  (matching
           that character taken as an ordinary character, as if the `\' had
           not  been  present(!)), or a single character with no other sig-
           nificance (matching that character).  A `{' followed by a  char-
           acter  other  than  a  digit  is  an ordinary character, not the
           beginning of a bound(!).  It is illegal to end an RE with `\'.
    
    The "null string at the end of a line" means that the $ doesn't gobble
    any characters in the matching line.  Precise, tho not exactly
    vernacular.
    
    BTW, with some versions of sed you can use \r to specify the CR
    character.
    
    > "REGULAR EXPRESSIONS
    > POSIX.2 BREs should be supported, but they aren't completely because of
    > performance  problems.  The \n sequence in a regular expression matches
    > the newline character, and similarly for \a, \t, and other sequences."
    > 
    > All I could find on POSIX.2 BREs defines "$" in terms of "the end of a
    > line":
    > 
    > http://docsrv.sco.com:507/en/man/html.M/regexp.M.html
    > 
    > http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03
    > _08
    > 
    > I can only surmise sed is thus free to treat "^M" as part of the RE or
    > as part of the "end of a line", and opts for the former.
    
    No.  Under Windoze ^M^J *is* a new line.  Under *nix, ^J is newline.
    So if you pass a ^M^J to Linux that ^M is seen as just another
    character, and treated as such.  If you want to change it to
    some other character or string using sed, you are free to do so.
      sed -e "s/^M/Bogus Newline/"
    
    And this is how it should be.  Because if sed accepted *either*
    ^M^J or ^J as a new line then how would we specifically handle
    files that had a mix of these if we wanted to treat the two
    differently?
    
    Having programs try to do what they think you want rather than
    what you specifically say may feel good when you are first
    starting.  But pretty soon then get in the way when you try
    to do something difficult.
    
    > Cheers,
    > --Jason V. C.
    > --
    > Revolution from Below! GPL the Constitution!
    
    The Constitution already is open source.  Fortunately.
    And most of the laws are.  Exception: "patriot act".
    
    The comment below describes Bill Gates and clan...
    --
    Allen Brown
      work: Agilent Technologies      non-work: http://www.peak.org/~abrown/
            allen_brown at agilent.com             abrown at peak.org
      Those who do not understand Unix are condemned to reinvent it, poorly.
        --- Henry Spencer
    
    
  • Resolved: [Eug-lug] Source Code Processing



    Jason Van CleveThu May 5 20:54:34 PDT 2005

    Quoth Bob Miller, on Thu, 5 May 2005 18:11:06 -0700:
    
    > No, sed is precise with regard to newlines. (-: I was wondering if
    
    The man page isn't very.  It doesn't mention "$" wrt regex's, just "\n":
    
    "REGULAR EXPRESSIONS
    POSIX.2 BREs should be supported, but they aren't completely because of
    performance  problems.  The \n sequence in a regular expression matches
    the newline character, and similarly for \a, \t, and other sequences."
    
    All I could find on POSIX.2 BREs defines "$" in terms of "the end of a
    line":
    
    http://docsrv.sco.com:507/en/man/html.M/regexp.M.html
    
    http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03
    _08
    
    I can only surmise sed is thus free to treat "^M" as part of the RE or
    as part of the "end of a line", and opts for the former.
    
    Cheers,
    
    --Jason V. C.
    
    --
    Revolution from Below! GPL the Constitution!
    
  • [Eug-lug] Re: Today’s Firefox Tip



    bogan smytheThu May 5 20:26:55 PDT 2005

    Slik tip, Bob.  (Hotkeys rule; mice are rodents).
    
    Thanx, for sharing this one,
    M
    
    On 06-May-05, you wrote:
    
    > I just discovered, more or less by accident, that in Firefox,
    > Control-Return opens the currently selected link in a new tab, without
    > switching to it.
    > 
    > That means that you can use Tab and Shift-Tab to sequence through
    > all the links on a page, and use Control-Return to open the interesting
    > ones in the background, all without touching the rodent.
    > 
    > Since the rodent on my laptop is a trackpad which I can't manipulate
    > very accurately, that saves me a lot of time and frustration.
    > 
    > I couldn't find this in Firefox Help, BTW.
    > 
    Regards
    -- 
        http://world.lookscool.com
        http://www.efn.org/~mikemcoo
    
    "Did you know that in Antarctica,  nighttime temperatures can plunge to -120
    degrees?"
    
    "Yeah, but it's a DRY cold . . . "
    
    
    
  • Resolved: [Eug-lug] Source Code Processing



    Jason Van CleveThu May 5 20:21:20 PDT 2005

    Quoth Bob Miller, on Thu, 5 May 2005 18:15:25 -0700:
    
    > If you want to strip whitespace and preserve DOS line endings, try
    > this.
    > 
    >    $ sed -e 's/[ ^I]+\(^M?\)$/\1/'
    
    Thanks, KBob, I can use that.
    
    --Jason
    
    --
    "Out of environment space" -- MS-DOS Command Interpreter
    
  • Resolved: [Eug-lug] Source Code Processing



    horstThu May 5 19:39:51 PDT 2005

    > Date: Thu, 5 May 2005 14:58:01 -0700
    > From: Jason Van Cleve <jason at vancleve.com>
    ..>
    > Actually, the DOS newlines themselves were not my problem, and I didn't
    > <i>want</i> to change them necessarily.  It was that they were confusing
    > sed so that my regular expression didn't work.  To my simple mind, DOS
    > newlines are newlines too, and so "$" should match them.  Unless it is
    
    "$" is the end of line (text line as I understand it, before the 'newline' 
    char(s)
    The casual term 'newline' has different meanings on different OSes.
    On nix it's 0A	(hex, i.e 10 decimal)
    On DOS it's 0D 0A  (2 bytes, 13 and 10)
    On Mac it's 0D
    
    Of course, above bytes have conventional names NL and CR as you maybe able 
    to see when you run 'man ascii' , but the newline '\n' used in programming 
    languages, and some shell programs is just a symbol that is translated 
    according to the OS. As I recall that holds for C++ and java. But I am 
    sure in python, as the one line below yield different files 'test' , 3 
    bytes on nix, 4 bytes on DOS:
      python -c "fout = open('test', 'w') ; fout.write('Hi\n') ; fout.close()"
    
    So if I *want* to preserve the individual OS-style newline with a mix of 
    files I'd use a programming language, in my case python, and handle the 
    '0A' and 'OD' directly (w/o '\n' translation).
    
      - Horst, in vi ^M is ctrl-v ctrl-m.
    
    
  • Resolved: [Eug-lug] Source Code Processing



    Bob MillerThu May 5 18:15:25 PDT 2005

    Jason Van Cleve wrote:
    
    > Actually, the DOS newlines themselves were not my problem, and I didn't
    > <i>want</i> to change them necessarily.  It was that they were confusing
    > sed so that my regular expression didn't work.  To my simple mind, DOS
    > newlines are newlines too, and so "$" should match them.  Unless it is
    > unreasonable to expect sed to account for that when pattern matching,
    > then it would seem sed could do its one thing that much better.
    
    If you want to strip whitespace and preserve DOS line endings, try this.
    
       $ sed -e 's/[ ^I]+\(^M?\)$/\1/'
    
    (^I and ^M are TAB and CR characters, octal 011 and 015.)
    
    -- 
    Bob Miller                              K<bob>
    kbobsoft software consulting
    http://kbobsoft.com                     kbob at jogger-egg.com
    
  • Resolved: [Eug-lug] Source Code Processing



    Bob MillerThu May 5 18:11:06 PDT 2005

    Jason Van Cleve wrote:
    
    > Evidently sed is stupid with regard to newlines
    
    No, sed is precise with regard to newlines. (-: I was wondering if
    converting DOS line ends to Unix would be your next question.
    
    -- 
    Bob Miller                              K<bob>
    kbobsoft software consulting
    http://kbobsoft.com                     kbob at jogger-egg.com
    
  • [Eug-lug] [Fwd: unix geeks for hire?]



    Rob HudsonThu May 5 16:00:04 PDT 2005

    EUGLUG,
    
    My friend Matt Jarvis is looking for some help setting up a Unix 
    machine.  The specifics are as follows:
    
    We have a Compaq ML530 that was originally set up for Windows, we want 
    SCO Unix 5.05 installed and the disk array properly configured. Have the 
    disks but might need help setting up an ISO disk for the installation. 
    Also want a SCSI External tape backup installed.
    
    I've been told that he is authorized to pay $25/hr.
    
    If you're interested, reply to me and I'll forward your contact info on.
    
    Thanks,
    Rob
    
    
  • [Eug-lug] USB Memory Sticks



    Jeff NewtonThu May 5 15:03:16 PDT 2005

    Hey Guys,
    
    I'm looking into getting one of those media memory sticks to use here, was 
    wondering if anyone has any recommendations on what to look into??
    
    Thanks -
    
    Jeff
    
  • Resolved: [Eug-lug] Source Code Processing



    Jason Van CleveThu May 5 14:58:01 PDT 2005

    Quoth larry price, on Thu, 5 May 2005 14:16:09 -0700:
    
    > the one thing that sed does well is edit streams of text, it does not
    > do so well at guessing what you want, you have to tell it if you want
    > it to change line-endings etc.
    
    Actually, the DOS newlines themselves were not my problem, and I didn't
    <i>want</i> to change them necessarily.  It was that they were confusing
    sed so that my regular expression didn't work.  To my simple mind, DOS
    newlines are newlines too, and so "$" should match them.  Unless it is
    unreasonable to expect sed to account for that when pattern matching,
    then it would seem sed could do its one thing that much better.
    
    --Jason V. C.