[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Search and Replace



John Greer hat gesagt: // John Greer wrote:

> I know that this is not Debian specific but I thought I would give it a 
> shot anyway.  I need to search a series of files for a text string 
> (grep I know) and then I need to replace that string with another.  Is 
> there a command or string of commands that I can do this in?  If 
> this is possible it will make my life much easier!!  Thanks 

And here's my favourite one(liner) in perl:
$ perl -p -i.bak -e "s/foo/bar/" *.txt

Replaces foo with bar in every file ending in .txt and makes backups.
See man perlrun 
-- 
                                                     __    __
 Frank Barknecht           ____ ______   ____ __ trip\ \  / /wire ______
                          / __// __  /__/ __// // __  \ \/ /  __ \\  ___\	
                         / /  / ____/  / /  / // ____// /\ \\  ___\\____ \	
                        /_/  /_____/  /_/  /_//_____// /  \ \\_____\\_____\
                                                    /_/    \_\ 


Reply to: