View previous topic :: View next topic |
Author |
Message |
dleifelohcs Apprentice
Joined: 10 Jul 2003 Posts: 160 Location: UNH
|
Posted: Mon Feb 23, 2004 3:43 pm Post subject: Scripting..(?) Batch find/replacer |
|
|
I have, say, 500 files that all have this one line in them.
This line needs to be replaced with a different line. What can I do to find/make a sort of batch, multi-file replacer? (Each file is different, but they all have this one line in them, only once)
I know this isn't Gentoo specific, but I didn't know where else to look!
Thanks |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Mon Feb 23, 2004 4:15 pm Post subject: |
|
|
Use rename:
Code: | rename oldline newline * |
_________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
Posted: Tue Feb 24, 2004 6:17 am Post subject: |
|
|
Use sed -i or perl -p -i -e. |
|
Back to top |
|
|
charlieg Advocate
Joined: 30 Jul 2002 Posts: 2149 Location: Manchester UK
|
Posted: Tue Feb 24, 2004 9:23 am Post subject: |
|
|
tomk wrote: | Use rename:
Code: | rename oldline newline * |
|
I thought that only worked on file names? (Hence the name 'rename'...) _________________ Want Free games?
Free Gamer - open source games list & commentary
Open source web-enabled rich UI platform: Vexi |
|
Back to top |
|
|
neilhwatson l33t
Joined: 06 Feb 2003 Posts: 719 Location: Canada
|
Posted: Tue Feb 24, 2004 2:45 pm Post subject: |
|
|
Code: |
find <path> -name file.* -exec perl -pi -e 's/old/new/gi' {} \;
|
_________________ The true guru is a teacher.
Neil Watson |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Wed Feb 25, 2004 1:48 pm Post subject: |
|
|
charlieg wrote: | I thought that only worked on file names? (Hence the name 'rename'...) |
Whoops I must have totally misread the question. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
|