Reputation: 961
I need to replace a bunch of
&p_Data->scratchBuffer0_U32[ 0 ]
with
scratchBuffer0_U32
in a tons of c files in a directory and its sub-directories.
Also, some developers wrote the [ 0 ] as [0] and [ 0]
Upvotes: 0
Views: 41
Reputation: 1667
This would be work:
find your_directory -name "*.c" | xargs sed -i 's/&\(p_Data->scratchBuffer0_U32\)[^]]*]/\1/g'
Upvotes: 1
Reputation: 203712
With GNU sed for -i
for pseudo-inplace editing:
find . -type f -exec sed -i 's/&p_Data->scratchBuffer0_U32\[[[:space:]]*0[[:space:]]*\]/scratchBuffer0_U32/g' {} +
Upvotes: 0
Reputation: 1147
If you are using *nix and you are trying to replace a string in multiple files, check out this answer here which shows you how to do a recursive replacement with find and perl.
As per the difference between the brackets, you'll have to run it for all 4 cases -- [0], [ 0], [0 ], and [ 0 ].
Upvotes: 0