[英]how to find and replace [0-9]* inside a file, linux
how can you find [0-9] as this is treated as a pattern by linux 您如何找到[0-9],因为Linux将其视为一种模式
Need to search for 10.179.[0-9]*.150 and replace it with 10.179.227.150 inside a file 需要在文件中搜索10.179。[0-9] *。150并用10.179.227.150替换
sed 's/10\.179\.[0-9]*\.150/10.179.227.150/g' input.txt >output.txt
或者,如果您必须将[0-9]*
视为文字字符串,而不是任何数字,请在上面将其转义为\\[0-9\\]\\*
。
If [0-9]*
is a regex pattern: 如果
[0-9]*
是正则表达式模式:
sed -i s/10\.179\.[0-9]*\.150/10.179.227.150/g file.txt
If [0-9]*
is to be taken literally: 如果将
[0-9]*
从字面上理解为:
sed -i s/10\.179\.\[0-9\]\*\.150/10.179.227.150/g file.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.