![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to change the replace the String in sub folders | bobbygsk | UNIX for Dummies Questions & Answers | 6 | 09-30-2008 09:09 AM |
| change string in file | kamel.seg | Shell Programming and Scripting | 1 | 01-07-2008 04:45 AM |
| How to change only the x first characters of a string? | Juha | Shell Programming and Scripting | 2 | 09-28-2007 05:17 AM |
| replace character in a string pattern and save the change in same file | mihir0011 | Shell Programming and Scripting | 2 | 09-26-2007 02:31 PM |
| Change the a string in the file | kamathg | Shell Programming and Scripting | 3 | 08-08-2007 05:14 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Change a string
I have my.cnf file:
[mysqld] log-bin = mysql-bin relay-log = relay-bin #skip-slave-start ...... If there is no "skip-slave-start", I want to add it. Or uncomment if it presents and commented. Could someone tell me how to implement this feature in the easiest way? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
try this shell script:
Code:
#!/bin/bash
grep '^skip-slave-start' my.cnf >& /dev/null
if [ $? -ne 0 ] ; then
echo "skip-slave-start is not turned on, so going to turn it on..."
grep '^ *# *skip-slave-start' my.cnf >& /dev/null
if [ $? -eq 0 ] ; then
# skip-slave-start is commented
sed -i 's/^ *# *skip-slave-start/skip-slave-start/' my.cnf
# so uncommnt it
else
# skip-slave-start is not present
sed -i 's/\[mysqld\]/[mysqld]\nskip-level-start/' my.cnf
# so add it in [mysqld] section
fi
else
echo "skip-slave-start was turned on"
fi
|
||||
| Google The UNIX and Linux Forums |