The UNIX and Linux Forums
>
Top Forums
>
Shell Programming and Scripting
replacing specific lines in a file
.
User Name
Remember Me?
Password
google unix.com
Forums
Register
Forum Rules
Links
Albums
FAQ
Members List
Calendar
Search
Today's Posts
Mark Forums Read
Thread
:
replacing specific lines in a file
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
#
7
(
permalink
)
09-30-2006
mph
Registered User
Join Date: Mar 2006
Posts: 58
You might try something like this if you don't want to create a file:
Code:
echo '%s/oldtext/newtext/g\nwq' | ex file
This will edit the text within the file. Non interactive style
vi
. The exact syntax for ex is a bit murky I can't find a lot of docs on it, but in a few occasions it's well worth figuring out and using.
mph
View Public Profile
Find all posts by mph
Find mph's past nominations received
Find mph's present nominations given