When writing scripts,I often like to insert text into a file at a very specific location/line. The following lines of code, will enable rsync comment out the line starting with default_password_crypted insert a new line with default_password_crypted in it's place [root@rhnsat01 ~]# sed -i -e 's/\=\ yes/\=\ no/g' /etc/xinetd.d/rsync [root@rhnsat01 ~]# sed -i -e 's/default_password_crypted:/#default_password_crypted:/g' /etc/cobbler/settings [root@rhnsat01 ~]# MYPASS=`openssl passwd -1 -salt 'Passw0rd' 'Passw0rd'` [root@rhnsat01 ~]# sed -i -e '84i'${MYPASS}'' /etc/cobbler/settings In vi, to see the line you are on (I don't know how to turn the numbers back off though ;-) : set number
Linux: The whole world made it for you... This blog is a collection of things I come across either at home or at work as a Linux Administrator. I have worked as an Admin working with Solaris, SAN, Backups and Linux at the Enterprise level for over 16 years.