Answer the question
In order to leave comments, you need to log in
How to uncomment a complex line with Ansible?
Good afternoon!
Given:
file with three lines
--awful.util.spawn('sh -c "sleep 5s && one"')
--awful.util.spawn('sh -c "sleep 5s && two"')
--awful.util.spawn('sh -c "sleep 5s && three"')
- replace:
dest=/home/{{ desktop_user }}/.config/awesome/rc.lua
regexp="--awful.util.spawn(\"sh -c \"sleep 5s && two\"')"
replace="awful.util.spawn(\"sh -c \"sleep 5s && two\"')"
Answer the question
In order to leave comments, you need to log in
- replace:
dest=/home/{{ desktop_user }}/.config/awesome/rc.lua
regexp="\-\-awful\.util\.spawn\(\'sh\ \-c\ \"sleep\ 5s\ \&\&\ one\"\)"
replace="awful.util.spawn('sh -c \"sleep 5s && two\"')"
import re
print re.escape("""--awful.util.spawn('sh -c "sleep 5s && one")""")
# \-\-awful\.util\.spawn\(\'sh\ \-c\ \"sleep\ 5s\ \&\&\ one\"\)
It’s better to put such files into templates and it’s easy to implement any logic there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question