我正在尝试使用bash脚本在UserDataEntry
Name
项目中的header file (.h)
中的某些代码行插入编码的加密内容。另外,我在Xcode
工作。
我现在的脚本代码是:
Objective-C
当我从终端执行脚本时,我得到下一个错误:
mac (OS X)
错误:文件名太长
如果sed -n '' "10i
$jsonConfigFileContent
" Sources/ConfigurationInteractor.h
较小(字符较少),则插入正常。但是当这个字符串很大时,我得到了这个错误。如何在header(h。)文件中的某行代码中插入大字符串以及如何修复此错误?谢谢你的回答。
修改 我在这个脚本中使用的另一个代码是:
sed: 10i
#define jsonConfigFileContent @"CwtTuNRnWcO2HJfytXDYMnoeRQnZOGbEW6/f6uYS1TM2uUSvvEQQXwUH7D6iU5HQNoKuYvfW4vp4YUqsQ9oFXga2Dz/SQsALNouAi9hDNfr+AaE9i7RW6hUYZuu742xage9l9m8+4bWudiJiCKBVH+2gXN8qhoopa/46en9XYPr78warXotiGxBzrkCP2kBic1lGlAabQy4LEMMRklOShsyxZqb6sw4Pl5PZlp9G9vF1u1+IOPkmfG82JgcvJTsXFcs+yyedZERhkGMKL+crKewMlnQLj0k49KaptKYBLRtbq98y/yXAqN9kWc8eZhKw9Ov+sVz2kHcjOhVGgUY8eY6wMqo9jndDWx9bmxiu6gVvtU1i1ycZedBJWxAfq3XFBzB+kII5+ufVfIO93yNqNAByjnzNTkCxJ2ko/P8fYeppNmmn/Y6aBi9qQ9u1j1clt37ylYogOnOB9ph+qCoT640Z+0/HponVG1JFSiY3j1EvxA0lT4qh8SlLm5BpIL5tUfJ913k7hrdEVl1pA30MvDw2LUDB/hNG1B//dVuqb+LN4XFS7Ckac53xko4z1txrADTT2cOJKwZlOHWCMKtGJC9n6xmZAzOBqqQiPCTqxQw2FSxyVcJqGe6lstWfzXDUZYtzofvsdj6+Gdg5dz9YYESr9mAIpD5wuMTi9WKf4yeV735I9JtzOhXDGljLpDB8F0riUAVatzq7YQ8LGNfsNIg9eMD8uSnBRDUCEwCB5IdAfXlLY2w6h/Hm2TUOYgrP/pEzwmBP1na/jh/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w7+3lKNLXY+N4yz0LFw7fKVMFyAY19wqWATlx/wAZ+DpvR4Z2m1c0o2F59AofV4F6+2ePwsbJJD05ezNtjkb9AwY1X2Q67ZN5tVxKZa5AfCWSXMui117WH9f4CjY1WP2s0ZkN78cPNkaAywzgM/5yKckrYAJuUetTpPuzNQi1TBAxcpfJZZwbf5U/KY4Ab/yaQKKjJ9FN5ub2e5VF8T/uVXf0LzEDrJaOTQPcK+A3+fbvEBXobOM3odlZTezqQoZ/hpZQtflTzZj8eCRN+WAIQMqU7XvBGH4mC/gDhEcph5g2MpKVYlxLSj3FW70LzHbg6HEzCEX/9+dJp+XBfExVT5Z9JKnLcWMbPAGKwhJlAG3AB1s4Euvgq+vq0GZmWiJfi0C20d+OTWqDGkWLEQ2k1yhpbA7mHchFvkvDJHccuUifNVHEVsVhAKI+ZlASZmxi+H0M5rpM6NSgJiYPTnIt1oT+78GLDdO/xrck+ic8FIjAuTR8vZZ/FxllFIl6FUu8sv5zjVRd40f/b/UgtyTocRkZ6DPPGYXuv5/rJgGHiGA59JjZ78R1FpWkPObkU/gX5kp5nWIyaprsVVgnzp5ultcPGlTp0JvpihoT08x051FC+7JRqrp5NPJpAkrky45spLD0h8w5GXkQ6VQALMKZjaUzc6D7Iq6Fek="
但我会收到此错误:
jsonConfigFileContent
对于较小的字符串也可以正常工作,但是当字符串很大时它不起作用。除sed -i -e "10i\
$(echo $jsonConfigFileContent)
" Sources/VWConfigurationInteractor.h
之外,我得到相同的错误,但字母不同。
答案 0 :(得分:0)
如果你可以使用awk。
在变量中设置值(带单引号):
a='#define jsonConfigFileContent @"CwtTuNRnWcO2HJfytXDYMnoeRQnZOGbEW6/f6uYS1TM2uUSvvEQQXwUH7D6iU5HQNoKuYvfW4vp4YUqsQ9oFXga2Dz/SQsALNouAi9hDNfr+AaE9i7RW6hUYZuu742xage9l9m8+4bWudiJiCKBVH+2gXN8qhoopa/46en9XYPr78warXotiGxBzrkCP2kBic1lGlAabQy4LEMMRklOShsyxZqb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llFIl6FUu8sv5zjVRd40f/b/UgtyTocRkZ6DPPGYXuv5/rJgGHiGA59JjZ78R1FpWkPObkU/gX5kp5nWIyaprsVVgnzp5ultcPGlTp0JvpihoT08x051FC+7JRqrp5NPJpAkrky45spLD0h8w5GXkQ6VQALMKZjaUzc6D7Iq6Fek="'
然后执行:
$ awk -v a="$a" 'NR==3{printf("%s\n",a)};1' Sources/ConfigurationInteractor.h
答案 1 :(得分:0)
我设法解决了这个问题。在头文件中,我必须将模式变量添加到特定的代码行。而且在bash脚本中我添加了:
sed -i "" "s|#define jsonConfigFileContent.*|$(echo $define$jsonConfigFileContent$lastMark)|g" Sources/ConfigurationInteractor.h
它终于奏效了。