Skip to content

Instantly share code, notes, and snippets.

@Asenar
Asenar / an-other-one.sh
Last active October 5, 2015 10:28
massive search and replace multiline when you have an old html website to modify. Theses scripts has been used to add google analytic tracker in <head> , and to convert an html website to "basic php", replacing html main blocs like headers, footers and menus by a php inclusion + renaming file html to php
#!/bin/bash
# Author: Michaël Marinetti
# Description: in each files ( $ext extension)
# if they not contains $search add $content (absolute path) before $add_before (a vim regex, beginning with / or ?)
dir=www
ext="htm"
search="_setAccount"
content=~/correct-html-header
add_before="/<\/head>/-1"
<?php
private function getCurrentRule() {
$return = false;
$rules = array_reverse($this->getRules());
$today = time() ;
$year = Date('Y') ;
$day = Date('d') ;
$month = Date('m') ;