Re: Replacing text within a bunch of files

From: Ed Wilts (ewilts_at_ewilts.org)
Date: 04/10/04

  • Next message: Simran Hansrai: "PHP Code"
    Date: Sat, 10 Apr 2004 15:21:46 -0500
    To: Chris <redhat-list@dotcomdesigners.com>, General Red Hat Linux discussion list <redhat-list@redhat.com>
    
    

    On Sat, Apr 10, 2004 at 01:17:33PM -0700, Chris wrote:
    > Okay, one more small question :-)
    >
    > Can you force it to apply only to certain files, say *.html ?

    Sure - just change the find command.
    >
    > It's trying to do this in binary files and all sorts of files that
    > either won't have the string I'm trying to replace, or should not even
    > attempt to modify such other files - just html documents.

    find -name '*.html' -type -f

    find has a *lot* of options that let you be as specific as you want to
    be.

            .../Ed
    > ----- Original Message -----
    > From: "Chris" <redhat-list@dotcomdesigners.com>
    > Sent: Saturday, April 10, 2004 1:10 PM
    > Subject: Re: Replacing text within a bunch of files
    >
    >
    > > Thanks Ed!!
    > >
    > > That works perfectly.
    > >
    > > Adam
    > >
    > > ----- Original Message -----
    > > From: "Ed Wilts" <ewilts@ewilts.org>
    > > Sent: Saturday, April 10, 2004 12:49 PM
    > > Subject: Re: Replacing text within a bunch of files
    > >
    > >
    > > > find -type f | xargs -n 1 replace old_string new_string --
    > > >
    > > > The latter will do an inplace replacement.

    -- 
    Ed Wilts, Mounds View, MN, USA
    mailto:ewilts@ewilts.org
    Member #1, Red Hat Community Ambassador Program
    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Simran Hansrai: "PHP Code"

    Relevant Pages

    • Re: System call not acting as expected
      ... You seem to be expecting the latter behaviour, ... Why are you using commas there ... all sorts of fun problems, like having to sort out terminal escape ... > The result of this line confirms that it is generating exactly the command ...
      (comp.lang.perl.misc)
    • Re: Trouble reading binary zeroes from a file
      ... or at least those Elvis fans who use JPSoft ... >"Most instances" should be parsing of binary files in general, ... command is crucial. ... speed to some degree, but good, solid functionality is worth ...
      (comp.os.msdos.4dos)
    • Re: Ruled text
      ... defining a command to lay out examples in the form of text (perhaps ... containing all sorts of stuff beyond simple paragraphs) set off by ...
      (comp.text.tex)
    • Re: How to change the information in audio files?
      ... information and/or the sound format in audio files? ... I'd prefer command line ... is a library for editing all sorts of metadata on all sorts of audio ...
      (uk.comp.os.linux)
    • Re: [SLE] Where are logins recorded?
      ... [SLE] Where are logins recorded? ... > I had an unexpected crash in the early hours of this ... last would be the command. ... wtmp and btmp are binary files that cannot be edited. ...
      (SuSE)