Collection of mostly command line tools / PHP scripts. Somewhat out of date.

⌈⌋ ⎇ branch:  scripts + snippets


Check-in [c66385ed29]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:file replace cmdline tool
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c66385ed299c87ca16cab07578681bc28c670a9d
User & Date: mario 2012-01-09 04:14:29
Context
2012-01-09
04:15
work on php plugin standard files and extract version:\d+ field, while epm_set_version can update epm packaging .list files Both tools have been superseded by <a href=https://fossil.include-once.org/versionnum/>versionnum/</a> check-in: 94410824fb user: mario tags: trunk
04:14
file replace cmdline tool check-in: c66385ed29 user: mario tags: trunk
04:13
functioning version of apt-phparchive check-in: beb19b64e0 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added fr.















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w

## require("/home/mario/public_html/x/sh-lib.pl");

($PATTERN, $REPLACEMENT, @files) = @ARGV;

if ($PATTERN && $REPLACEMENT && @files) {


if ($#files < 0) {
   @files = ("-");
}
elsif (!$files[0] eq "-") {
   print "fr: replacing `$PATTERN' with `$REPLACEMENT'\n";
}


foreach $file (@files) {

  if ( (! ($file eq "-")) && (! -f $file || ! -r $file) ) {
     next;
  }

  open READ, "$file";
  @text = (<READ>);
  close READ;

  $text = '';
  foreach $line (@text) {
    $text .= $line;
  }

  @numfound = ($text =~ /($PATTERN)/igs);
  $numfound = $#numfound + 1;
  if ($numfound >= 1) {

    $text =~ s/$PATTERN/$REPLACEMENT/igs;

    if (! ($file eq "-")) {
       print "$numfound replacing in $file\n";
    }

    open WRITE, ">$file";
    print WRITE $text;
    close WRITE;

  }
}

}
else {
  print "\nfr PATTERN REPLACEMENT files...\n\nwill replace any occourences of ".
        "PATTERN with REPLACEMENT in given files\n(use `find` in place of ".
        "\"files...\")\n\n";
}