RE: Replace a string inside a file

From: Sites, Brad (BSites_at_mem-ins.com)
Date: 09/15/03

  • Next message: Aly Dharshi: "Automounting ISO's"
    To: "'redhat-list@redhat.com'" <redhat-list@redhat.com>
    Date: Mon, 15 Sep 2003 14:10:14 -0500
    
    

    Keith Birchfield wrote:
    > Hello all, and thanks for previous help! :-)
    >
    > Can anyone give me a csh cheat to copy a file with a specific string
    > replaced with another?
    >
    > For example
    > copy foo1.txt to foo2.txt and replace each instance of "blue" with
    > "red" where
    > foo1.txt contains
    > apple
    > blue syrup
    > green apples
    > blue
    > red grapes
    > grapes
    >
    > and the resulting foo2.txt contains
    > apple
    > red syrup
    > green apples
    > red
    > red grapes
    > grapes
    >

    cat foo1.txt |sed 's/blue/red/' > foo2.txt

    If you have in foo1.txt the text 'bluegreen apples', the above would change
    it to be 'redgreen apples'. To separate out the words as single words do:

    cat foo1.txt |sed 's/blue /red /' > foo2.txt.

    Or do man sed for further information on ways to do the search and replace
    you are wanting to do.

       .~. Brad Sites
       /V\ Systems Administrator
      // \\ Missouri Employers Mutual Insurance
     /( )\ bsites@mem-ins.com www.mem-ins.com
      ^^-^^ (573) 499-4230

    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Aly Dharshi: "Automounting ISO's"

    Relevant Pages

    • Re: The substance from green apples
      ... "his coercion of the substance from green apples"? ... Irish Road Bowling Association ... Bowl playing, road bowling, road bowls. ... of the substance from green apples. ...
      (alt.usage.english)
    • Re: Free Will
      ... or without consciousness per se - in the way we are conscious. ... build in the pain-response behaviors without the need for qualia. ... So, we build one of these machines, and show it red and green apples. ...
      (comp.ai.philosophy)
    • Re: The substance from green apples
      ... "his coercion of the substance from green apples"? ... of the substance from green apples. ...
      (alt.usage.english)
    • Re: automatically update data validation selections
      ... Validation "Columns") But change this so you fill in only the ID in the ... For> example, the named range includes: Apples, Oranges, Bananas. ... I want what the user selected> to now automatically reflect "Green Apples". ... I cannot> figure out how to accomplish this without using a combo box - but I> really don't want to use a combo box - just keep the user entry area> as cells. ...
      (microsoft.public.excel.misc)