[英]Search and delete a block using sed command in ubuntu
The thing I would like to perform is to 1- Find and 2- delete the whole definition block of (__c64): 我想执行的操作是1-查找并2-删除(__c64)的整个定义块:
unsigned long long __c64(unsigned int llvm_cbe_hi, unsigned int llvm_cbe_lo) {
unsigned long long llvm_cbe_retval; /* Address-exposed local */
unsigned long long llvm_cbe_retval1;
*(&llvm_cbe_retval) = (((((unsigned long long )(unsigned int )llvm_cbe_hi)) << 32ul) | (((unsigned long long )(unsigned int )llvm_cbe_lo)));
llvm_cbe_retval1 = *(&llvm_cbe_retval);
return llvm_cbe_retval1;
}
in all but one .c files in a project. 项目中除一个.c文件外的所有文件。 Since in the compilation phase of .o to the executable, I got the error "Multiple definition of __c64", I was thinking to delete all of those but one in order to solve the problem.
由于在从.o到可执行文件的编译阶段,我得到了错误“ __c64的多个定义”,因此我想删除其中的所有一个,以便解决该问题。
Any ideas? 有任何想法吗?
Regards, 问候,
Amir 阿米尔
If function layout is exactly same in all files you can try this 如果所有文件中的功能布局完全相同,则可以尝试此操作
gvim -p *.c // Open all relevant files in multiple tabs
then execute this 然后执行这个
:bufdo %s/unsigned long long __c64\(.\+\n\)\+\(\n\)\+\(.\+\n\)\+}// | update
"update" executed at the end will save each file. 最后执行的“更新”将保存每个文件。
guys as I found the definitions were dynamically changed, I tried to figure out sth like : 我发现定义是动态变化的,所以我试图找出……
sed '/^unsigned long long __c64/,/}/d'
and it did fortunately work. 幸运的是,它确实起作用了。
Thanks for all the helps. 感谢所有帮助。
Amir 阿米尔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.