zero-sys.net
Software Engineering, Administration, IT-Services & Consulting
ShortLiner


CLASS1=database.mysql.class.php; 
CLASS2=database.class.php; 
for i in `grep -e 'function *w* *(' $CLASS1 \
  | sed 's/function//g; s/([a-z,A-Z,_,,, ,=,",$,0-9]*) *{//g;s/[ ,\t]*//g'`;
do grep -q $i $CLASS2  ||  echo "missing $i"; 
done
Erstellt: 11.11.2005 19:41
Letzte Änderung: 11.11.2005 19:47


grep -r "( *defined" * | awk '{print $2}' | sed 's/if(defined("//g;s/" *)*{*$//g' | sort | uniq
Erstellt: 28.11.2005 12:40
Letzte Änderung: 28.11.2005 12:41


#!/bin/bash

declare -r SEARCH="string1";
declare -r REPLACE="string2";
declare -i DOBACKUP=1;
declare -r TEMPFILE=`tempfile`;

for f in `grep -R -c -I -l "$SEARCH" *`; do
    [ $DOBACKUP -eq 1 ] && cp "$f" "${f}.bak";
    cat "$f" | sed "s/$SEARCH/$REPLACE/g" > $TEMPFILE
    cat $TEMPFILE > "$f"
done

rm $TEMPFILE
Erstellt: 24.03.2006 11:32
Letzte Änderung: 24.03.2006 11:51


usefull if you like to move some scripts into another repository ...
#!/bin/bash

declare -r RCSTAGS="Date RCSfile Id Revision";
declare -r VALIDFILEEXTENSIONS="php html css js";
declare SEDREPLACE="";
declare -i DOBACK=1;

if [ $1 != "" ]; then
    if [ $1 = "-b" ]; then
        DOBACK=0;
    else
        echo "usage: $0 [-b]";
        echo "options:";
        echo -e "	-b:	make no backup of original files";
        exit 1;
    fi
fi

function cleanrcs () {
    #if test -z $1; then
    #   echo "call of $FUNCNAME w/out param";
    #   exit 1;
    #fi

    echo "cleaning "`pwd`;
    for FILE in *; do
        if test -d $FILE; then
            echo $FILE" is a dir ... recurse ...";
            cd $FILE;
            cleanrcs;
            cd ..;
        else
            FILEEXT=`echo $FILE | sed 's/^.*.//g'`;
            declare -i DO_RCS=0;

            if [ $FILE != $FILEEXT ]; then
                for EXT in $VALIDFILEEXTENSIONS; do
                    if [ $FILEEXT = $EXT ]; then
                        DO_RCS=1;
                    fi
                done
            fi

            if [ $DO_RCS -eq 1 ]; then
                cat $FILE | sed "$SEDREPLACE" > /tmp/basename"_$$";
                [ $DOBACK -eq 1 ] && cp -v $FILE $FILE".rcsbak";
                cp -v /tmp/basename"_$$" $FILE;
            else
                echo "ignoring $FILE";
            fi
        fi
    done
}

function buildsedreplace () {
    for rcs in $RCSTAGS; do
        SEDREPLACE=$SEDREPLACE's/$'$rcs':.*$/$'$rcs'$/g;';
    done
    echo $SEDREPLACE;
}

pwd;

buildsedreplace;
cleanrcs;

exit $?
Erstellt: 24.03.2006 11:09
Letzte Änderung: 24.03.2006 11:51