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
SHA1 Hash:c66385ed299c87ca16cab07578681bc28c670a9d
Date: 2012-01-09 04:14:29
User: mario
Comment:file replace cmdline tool
Tags And Properties
  • branch=trunk inherited from [3733c93d1a]
  • sym-trunk inherited from [3733c93d1a]
Context
2012-01-09
04:15
[94410824fb] 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> (user: mario, tags: trunk)
04:14
[c66385ed29] file replace cmdline tool (user: mario, tags: trunk)
04:13
[beb19b64e0] functioning version of apt-phparchive (user: mario, tags: trunk)
Changes

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";
}