File: replaceinallfiles

package info (click to toggle)
kde-dev-scripts 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,612 kB
  • sloc: perl: 15,615; lisp: 5,627; sh: 4,560; python: 3,892; ruby: 1,386; makefile: 13; sed: 9
file content (23 lines) | stat: -rwxr-xr-x 465 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby

Orig="original Makefile.am contents follow"
Repl=""

require 'ftools'

hits=0
Dir["**/CMakeLists.txt"].each do |file|
   printf("file: %s\n", file)
   fileContents=IO.readlines(file)
   newFile=File.new(file, "w+")
   fileContents.each do |line|
      if line.include?(Orig)
         hits=hits+1
         break
#         next
         line[Orig]=Repl
      end
      newFile.printf("%s", line)
   end
end
printf("%d replacements made\n", hits)