I think you can do it with sed, but one trick would be to make sure you are
not writing out to the same file as you are reading from. This may be unique
to me, but I had a hell of a time trying to figure what was wrong with a
similar thing I was working on. It turned out to be that I had to bring in
one file, do the operation, write out to another file and then change the
name back to the original.

Anyways... Give this a try:

#cat filename | sed s/Test/Test\nTest1/g > filename2

That works for me... ymmv :-)

Mitchell

On 10/6/02 8:46 AM, "Shaw, Marco" <[EMAIL PROTECTED]> wrote:

> How can I do the following...
> 
> A file something like this:
> 
> <some lines>
> Test
> <some lines>
> 
> I want to end up with:
> 
> <some lines>
> Test
> Test1
> <some lines>
> 
> So basically, I want to replace "Test" with "Test<new line>Test1".  Can't seem
> to do it with sed, and would prefer to stay away from Perl.  It won't
> necessarily be on the same line number all the time either.
> 
> I could possibly read the entire file in:
> 
> While read line
> Do
> if [ "$line" = "Test" ]
> then {
> echo
> echo "Test1"
> }
> fi
> Done < ${FILE} > ${FILE}.tmp
> 
> Which I just thought of, but didn't try, since it seems "ugly".
> 
> Marco
> 
> 



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to