[英]How to find and replace an IP address in many archives in linux
Example:例子:
find /tmp/example -type f -print0 | xargs -0 sed -i 's/10.20.1.110/10.10.1.40/g'
I need replace 10.20.1.110 to 10.10.1.40 in all archives inside /tmp/example.我需要在 /tmp/example 中的所有档案中将 10.20.1.110 替换为 10.10.1.40。 But this command does not replace inside archives.
但是这个命令不会替换内部档案。
.xml, *.txt , *.py .
.xml、*.txt、*.py。 .jy .
.jy This archives types.
这归档类型。
These are not archives, but ordinary text file extensions;这些不是档案,而是普通的文本文件扩展名; thus, if the
sed
command doesn't work for you, there must be another reason.因此,如果
sed
命令对您不起作用,那么一定有另一个原因。 It may be that the command is executed with insufficient priviledges - sed -i
exits as soon as it cannot rename
its temporary output file to the input file (as it's the case if the containing directory has the sticky bit t
set and you don't own the file or the directory).可能是该命令在权限不足的情况下执行 -
sed -i
一旦无法rename
其临时输出文件rename
为输入文件就退出(因为如果包含目录设置了粘性位t
而您没有拥有文件或目录)。 Pay heed to error messages.注意错误信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.