Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uupsi!jpradley!jpr From: jpr@jpradley.jpr.com (Jean-Pierre Radley) Newsgroups: comp.unix.shell Subject: Re: Retaining file permissions Keywords: chmod, sed, awk Message-ID: <1991Feb24.181118.5925@jpradley.jpr.com> Date: 24 Feb 91 18:11:18 GMT References: <6039@ptsfa.PacBell.COM> Organization: NYC Public Unix Lines: 24 In article <6039@ptsfa.PacBell.COM> jlwestm@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@jpradley.jpr.com CIS: 72160,1341 Brought to you by Super Global Mega Corp .com