[Gllug] Awk Sed

Christian Smith csmith at micromuse.com
Fri Dec 7 11:39:05 UTC 2001


On Fri, 7 Dec 2001, Gordon Joly wrote:

>At 20:18 +0000 2001-12-06, Stig Brautaset wrote:
>
>>
>>$ sed -e 's/1/2/g' file > c && mv c file
>>
>>will change all occurences of "1" to "2" in file. I don't think sed can
>>do in-file replacements though, but I am sure someone can prove me wrong
>>(I would be quite glad if someone could, because I have missed that
>>feature).
>>
>>Regards,
>>Stig
>
>
>It is all on the name.
>
>sed = streaming ed (streaming editor)
>
>So, no, it will only edit streams (e.g. from files, sockets(?), or stdio etc).

If you want in place editing, use ed!

$ ed file <<EOF
g/<pattern>s//<replacement>/g
w
q
EOF
$

Easy.


>
>Gordo
>

-- 
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list