Monday, January 3, 2011

Script to replace a string with another string in a file.

Lets assume that the file name is test. The file test contains many lines and you want to replace a line with another line. 1) Make a file abc,sh. $ touch abc.sh 2) Insert the script into abc,sh. $ vi abc.sh press i, then paste #/bin/bash cat filename echo "enter the newstring" read new echo "enter the oldstring" read old sed -i "s/$old/$new/g" test 3) sh abc.sh Output: ------ enter the newstring new enter the oldstring old ---...

Script to Restore multiple accounts from another server. Cpanel.

Copy the backup files of cpanel in *.tar.gz to the new servers /home. After that open a screen. 1) $ screen 2)Then run the following script in the screen. $ for i in `cat file1`; do /scripts/restorepkg $i; done Note:in file1 the usernames must be present. For that run this script. (for i in `cat /etc/trueuserdomains`; do echo $i|cut -d . -f1; done > file1) 3)Then exit from screen. press ctrl + a +...

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews