replace a text string
- by shantanuo
I want to replace the date found at the end of the "datadir" line with the current date.
For e.g. my my.cnf file looks like this...
# head /etc/my.cnf
[mysqld]
#mount -t tmpfs -o size=102m tmpfs /mnt
#datadir=/mnt
read-only
datadir=/mysqlApr5
#datadir=/mysqlApr2
#datadir=/mysqlMar16
#datadir=/mysqlFeb25a
Most of the lines are commented. I need to find the datadir line that is not commented and then replace the /mysqlApr4 with /mysqlApr20
datadir=/mysqlApr20
If it is possible I will like to comment the older datadir path.
#datadir=/mysqlApr5
I can output the current date as:
date '+%b%d'
But I want to concat it with the word "/mysql" and replace or comment the current datadir line.