团队,我看到有多个类似的问题,但我确实尝试了一些答案,但仍然无法得到我想要的。我想将目录和子目录中所有文件中的文本“product-ui-test-creds.json”替换为“vaulted-product-ui-test-creds.json”
示例 grep
Command> grep product-ui-test-creds.json * -r
ci/product/verify-ui/e2e.jenkinsfile: product_Test_User = credentials('product-ui-test-creds.json')
deployments/product-ui/e2e/e2e.jenkinsfile: product_Test_User = credentials('product-ui-test-creds.json')
deployments/product-stuff/ui-ci/Jenkinsfile: CREDS = credentials('product-ui-test-creds.json')
预期产出
Command> grep vaulted-product-ui-test-creds.json * -r
ci/product/verify-ui/e2e.jenkinsfile: product_Test_User = credentials('vaulted-product-ui-test-creds.json')
deployments/product-ui/e2e/e2e.jenkinsfile: product_Test_User = credentials('vaulted-product-ui-test-creds.json')
deployments/product-stuff/ui-ci/Jenkinsfile: CREDS = credentials('vaulted-product-ui-test-creds.json')
我试过这个
LC_ALL=C find . -type f -name '*.txt' -exec sed -i '' s/product-ui-test-creds.json/vaulted-product-ui-test-creds.json/g {} +
或
find . -type f -name '*.txt' -exec sed -i '' s/this/that/g {} +
不提供任何输出,也不更改文件中的任何内容。
建议尝试:
sed -i 's/product-ui-test-creds.json/vaulted-product-ui-test-creds.json/g' $(find -type f)