Re: SED help........

From: Karsten M. Self (kmself_at_ix.netcom.com)
Date: 04/23/04

  • Next message: Karsten M. Self: "Re: SED help........"
    Date: Fri, 23 Apr 2004 11:55:55 -0700
    To: debian-user@lists.debian.org
    
    
    

    on Fri, Apr 23, 2004 at 11:39:32AM -0400, Ralph Crongeyer (ralph@crongeyer.com) wrote:
    > Hi all,
    >
    > I need some help with SED. I'm trying to insert a "command"/text at the
    > beginning of every line from one file and output to a new file like this:
    >
    > sed 's/.*/clamscan -ri -l /var/log/clamav/clamav-"$1".log
    > --move=/var/log/clamav/quarantine &/ /var/log/clamav/diff/diff.txt >
    > /var/log/clamav/virus_scan

    Showing a sample of the lines you're trying to change would be useful.
    It's hard to tell just from your (broken) regex substitution.

    > but sed givs me this error:
    > sed: -e expression #1, char 23: Unknown option to 's'

    A few things.

      - ".*" matches the whole line. Is this what you're trying to change?
        If you just want to match start of line, use '^' instead.

      - "/" is the default sed argument delimiter. If you're using "/"
        within your regex *OR* substitution, you must escape it ("\/") *OR*
        use an alternate delimiter. Generally some syntactic character will
        work, any of: ".,:|", etc.

      - sed expressions must be contained on one line.

      - sed expressions on the shell should include *both* open *and* close
        quotes.

    I think what you want is the following:
     
         sed 's,^,clamscan -ri -l /var/log/clamav/clamav-"$1".log --move=/var/log/clamav/quarantine,' \
             < /var/log/clamav/diff/diff.txt > /var/log/clamav/virus_scan

     
    > I have also tried to use the insert command i\ but it just inserts the
    > text on a new line above each of the lines read from the file instead of
    > just inserting the text at the beginning of each of the lines red from
    > the file?

    s/red/read/

    Correct.

    Peace.

    -- 
    Karsten M. Self <kmself@ix.netcom.com>        http://kmself.home.netcom.com/
     What Part of "Gestalt" don't you understand?
        Save Bob Edwards!       http://www.savebobedwards.com/
    
    

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    


  • Next message: Karsten M. Self: "Re: SED help........"

    Relevant Pages

    • Re: sysgen error
      ... sysgen for the entire BSP. ... error persists once I do the 'build and sysgen current project' command. ... while doing a build and sysgen for stratad project ... I did a clean and sysgen but it is showing the same error. ...
      (microsoft.public.windowsce.platbuilder)
    • Re: ssh-keygen command
      ... On Thu, 2004-06-10 at 12:55, Thiago Amaury Ferraz wrote: ... > root.. ... Someone can help me, showing a better command ...
      (Fedora)
    • Re: installing perl
      ... why the last command not showing 5.008 and instead shows ... If I were a butterfly I'd live for a day, / I would be free, just blowing away. ... This cruel country has driven me down / Teased me and lied, ...
      (comp.lang.perl.misc)
    • Re: Why did Google Finance show F going up past $25 on Saturday?! (then back down again)
      ... finance page, and still showing e.g. at ... If that's all you have to get your shorts in such a knot, ... quotes coming in. ...
      (misc.invest.stocks)
    • Re: Questioning Obamas Judgment in Picking Biden
      ... Well, now you've seen him without a teleprompter, out-performing ... McCain on every question, showing a command of facts, respect for his ...
      (rec.arts.theatre.musicals)