Retaining file permissions

Jean-Pierre Radley jpr at jpradley.jpr.com
Mon Feb 25 05:11:18 AEST 1991


In article <6039 at ptsfa.PacBell.COM> jlwestm at PacBell.COM (Jeff Westman) writes:
>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
>        
>        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
>

Instead of that last 'mv', try
	
	cat xyzyx > $i
	rm xyzyx

BTW, iz xyzyx what you use for a temporary file name? Why not $0$$ ?

 Jean-Pierre Radley   NYC Public Unix   jpr at jpradley.jpr.com   CIS: 72160,1341



More information about the Comp.unix.shell mailing list