Retaining file permissions

Tom Christiansen tchrist at convex.COM
Fri Feb 22 13:18:21 AEST 1991


>From the keyboard of jlwestm at PacBell.COM (Jeff Westman):
:I have a script that replaces a string with another.  The file is executable, 
:but when I run it through 'sed' I loose the executable attribute -- and I
:don't want to change my umask.
:
:Here's basically what I have:
:
:        #  Replace one occurance with another
         #  Replace one occurance with occurrence :-)
:        
:        print "Enter a \"from\" string:  \c" ;  read FROM
:        print "Enter a \"to\"   string:  \c" ;  read TO
:        
:        sed s/$FROM/$TO/gp $i > xyzyx
:        mv -f xyzyx $i

% perl -p -i -e "s/$FROM/$TO/g" xyzyx

Did you know that your set duplicates the lines matching $FROM? 
I assume this to be an error.

--tom
-- 
"UNIX was not designed to stop you from doing stupid things, because
 that would also stop you from doing clever things." -- Doug Gwyn

 Tom Christiansen                tchrist at convex.com      convex!tchrist



More information about the Comp.unix.shell mailing list