开发者

How to write a Fabric script that uncomments a particular line of a user's .bashrc file?

开发者 https://www.devze.com 2023-02-25 04:46 出处:网络
How would you write a Fabric script that uncomments the line #force_color_prompt=yes from the logged-in user\'s .bashrc file?

How would you write a Fabric script that uncomments the line

#force_color_prompt=yes

from the logged-in user's .bashrc file?

Note: This question is specifically about editing this particular line开发者_Go百科, not about simply appending force_color_prompt=yes to the end of the file and ignoring this line.


fabric do have api for that. fabric.contrib.files.uncomment

from fabric.contrib.files import uncomment
uncomment("~/.bashrc", "^#force_color_prompt=yes", char='#')
0

精彩评论

暂无评论...
验证码 换一张
取 消