Delete all PHP closing tags at the end of all files

Delete PHP closing tags
Delete PHP closing tags with Sublime Text 2

I wanted to delete all PHP closing tags (?>) from a PHP project. So I used the following regex in Sublime Text 2 to delete them. (The leftmost button activates regular expressions)

(\s*\?>\s*)\z$

It only replaces the closing tags at the end of the file (\z = EOF).
Be sure to apply this only on *.php, and not on *.tpl files.

Edit:
Slight modification for finding files without a newline at the EOF.
(\s*.(?!\s+))\z$

Script für mktorrent

Ein Script zum erstellen von Torrents. Einfach eine Datei oder einen Ordner angeben und mktorrent erstellt eine gleichnamige Torrentdatei.

#!/bin/bash
TAG="[TaG]"

if [ ! $1 = "" ]; then
    if [ -e "$1.torrent" ]; then
        rm "$1.torrent"
    fi
    mktorrent -v -l 21 -a http://localhost:2710/announce -n "$TAG$1" -o "$1.torrent" "$1"
    mv "$1" "$TAG$1"
else
    echo "Usage: mkt <file|dir>"
fi
exit 0

PHP-Shorttags ersetzen

Ich bin vor kurzem auf ein PHP-Projekt gestoßen, das Shorttags voraussetzt.
Da diese aber nicht empfohlen werden, habe ich mir mal ein Bash-Script gebastelt um die alle zu ersetzen.

[bash highlight=”7″]#!/bin/bash
if [ "$1" = "-h" ]; then
echo "Replaces short php open tags <? with <?php in all files of the current dir."
exit 0
fi

find ./ -name "*.php" -exec sed -i -e ‘s!<?php!#php_long_tag#!g’ -e ‘s!<?!#php_long_tag#!g’ -e ‘s!#php_long_tag#!<?php !g’ {} \;

echo "done"

exit 0[/bash]