how can you find [0-9] as this is treated as a pattern by linux
Need to search for 10.179.[0-9]*.150 and replace it with 10.179.227.150 inside a file
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:
sed -i s/10\.179\.[0-9]*\.150/10.179.227.150/g file.txt
If [0-9]*
is to be taken literally:
sed -i s/10\.179\.\[0-9\]\*\.150/10.179.227.150/g file.txt
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.