我在 Mac 中使用以下命令来替换字符串。 这里我有一个关于-print0的问题。有什么用?
find skeleton/src/IO.Swagger/Controllers -name '*.cs' -print0| xargs -0 sed -i "" "s/namespace IO.Swagger.Controllers/namespace Abc.GroupA.TableLocalService.Controllers/g"
最佳答案
使用-print0
,find
将使用空字符(零字节)分隔文件名。然后必须使用 -0
(或 --null
)调用 xargs
,我建议在脚本中使用长选项,这样可以提高可读性,并为交互式控制台中的一次性命令保留缩写)。
这样,您就可以在文件名中使用空格或任何字符,包括换行符。
关于linux - 以下命令中-print0的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56221518/