ttheimer
asked on
How to use sed to change file contents
New to sed... I have the following statement that when entered on the command line works properly to make the desired replacement. This version sends the result to stdout. I can also redirect to a new file by appending ">newfile". But I want to change the original file and when I redirect to the same file name I get an empty file. What am I missing? How do I change the original file?
sed '/^<script language=javascript><\!-- /,/^ -->/c<body>' sedtesttarget.html
Thanks.
sed '/^<script language=javascript><\!-- /,/^ -->/c<body>' sedtesttarget.html
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The --in-place (or -i) option was not noted in my [paper] reference text - found it in the man file. Works perfectly. Thanks.
New command:
sed --in-place '/^<script language=javascript><\!-- /,/^ -->/c<body>' sedtesttarget.html
New command:
sed --in-place '/^<script language=javascript><\!-- /,/^ -->/c<body>' sedtesttarget.html
ASKER
New command:
sed --in-place '/^<script language=javascript><\!-- /,/^ -->/c<body>' sedtesttarget.html