Search and Replace using 'sed' command

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I need to change copyright date across all pages:

sed -i 's/© 2009/\© 2010\g' */*.html

How to get it to all directories AND subdirectories?

Re: Search and Replace using 'sed' command

On 2010-08-06, Bruce wrote:
Quoted text here. Click to load it

    In bash4:

shopt -s globstar
sed -i 's/© 2009/\© 2010\g' **/*.html

    In other shells:

sed -i 's/© 2009/\© 2010\g' $( find . -type f -name '*.html' )

    (The latter assumes sensible filenames: no whitespace, etc..)

   Chris F.A. Johnson                          <
   Author:                                     =======================
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Site Timeline