I'm stuck on a problem when I'm trying to modify a crontab entry with sed and regex.
Content of the crontab :
40 09 21 02 * cd /toto/tata && ./script.sh 1>../log/script_customer1.log 2>../log/script_customer1.err #customer1 #type1 #editable
00 19 21 05 * cd /toto/tata && ./script.sh 1>../log/script_customer2.log 2>../log/script_customer2.err #customer2 #type1 #editable
My script :
cust_hrt="#customer1 #type1"
crontab -l | sed -e 's/\([0-9]*\) \([0-9]*\) \([0-9]*\) \([0-9]*\) \(.*${cust_hrt} #editable\)/30 22 25 05 \5/'
but it doesn't work. If I try directly with:
crontab -l | sed -e 's/\([0-9]*\) \([0-9]*\) \([0-9]*\) \([0-9]*\) \(.*#customer1 #type1 #editable\)/30 22 25 05 \5/'`
then it works.
I don't understand. Did I miss something with the variable ?
The variable inside single quotes isn't interpolated. It should work if you switch to using double quotes for your sed command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.