The Open Source Swiss Army Knife

/unix/unix_editors/sed/
/unix/unix_editors/sed/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /unix   /unix_editors   /sed 
Permalink: runsed.txt
Title: shell script to run sed with expressions in file
article options : please login   |  raw source view  

#!/bin/sh
for x
do

        echo "editing $x: \c"
        if test "$x" = sedscr; then 
                echo "not editing sedscript!"
        elif test -s $x; then
                sed -f sedscr $x > /tmp/$x$$
                if test -s /tmp/$x$$
                then
                        if cmp -s $x /tmp/$x$$
                        then
                                echo "file not changed: \c"
                        else
                                mv $x $x.bak 
                                cp /tmp/$x$$ $x
                        fi
                        echo "done"
                else
                        echo "sed produced an empty file\c"
                        echo "test your sed script"
                fi
                rm -f /tmp/$x$$
        else
                echo "original file is empty"
        fi

done
echo "all done"


Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top