[CentOS] replacing a line in a file

Alain Reguera Delgado al at ciget.cienfuegos.cu
Sun Jan 25 03:21:59 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jerry Geis wrote:
> I have a large file that has a line like:
> 
> bindaddr=0.0.0.0     ; some other text
> 
> I want to replace the 0.0.0.0 with my address 192.168.1.8 and remove 
> everything
> else on the line to get:
> 
> bindaddr=192.168.1.8
> 
> How can I do that?

you could try:

sed -e /bindaddr=0\.0\.0\.0/cbindaddr=192.168.1.8 yourfile.txt | less

if it does what you want then apply the changes with adding -i:

sed -i -e /bindaddr=0\.0\.0\.0/cbindaddr=192.168.1.8 yourfile.txt

Best Regards,
- --
Alain Reguera Delgado <al at ciget.cienfuegos.cu>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with CentOS - http://enigmail.mozdev.org

iD8DBQFJe9rXyXxCQEoXDZARAj5uAJ9ZYDXe443zZZivi1JRzmfnrMAH6wCgr0C0
pIJ9Wbb5ZNhHcjPMK7QO8cY=
=Lv+e
-----END PGP SIGNATURE-----


More information about the CentOS mailing list