[英]How to replace values which are in single quotes using a bash script?
Hello I have a text file called "sampleText.txt" which includes string line like this, 您好,我有一个名为“ sampleText.txt”的文本文件,其中包括这样的字符串行,
subscribe_key = 'sub-c-xx-xx-xx-xx-xx';
What I need is I need to change this subscribe_key value using bash script. 我需要使用bash脚本更改此subscription_key值。 So the given below bash script I used bt it did not work.
因此,下面给定的bash脚本我使用bt不能正常工作。 Hope You will help me to let it work, Any help would be greatly appreciated.
希望您能帮助我让它正常工作,任何帮助将不胜感激。 Thank You.
谢谢。
#!/bin/bash
sed -i.bak -r '/^subscribe_key/{s/"[^']+'"/"sub-c-123-456-789"/}' sampleText.txt
您可以使用此sed
,
sed -i.bak -r "/^subscribe_key/s/([^']+')([^']+)('.*)/\1sub-c-123-456-789\3/" yourfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.