TIP

Linux : find and replace with grep and sed

tomato13 2009. 11. 6. 11:28

http://ketan404.blogspot.com/2006/08/linux-find-and-replace-with-grep-and.html


ex1) 

grep -rl PATTERN directory/path/ | xargs sed -i 's/PATTERN/REPLACEMENT/g'


ex2)

find ./ -name "*.h" | xargs sed -i 's/#include <\/product\/cdmaone\/ubicell\/src\/OAMS\/A

GT_MAIN_Verizon\/src\/ruby\/insert.h>/\/\/#include <\/product\/cdmaone\/ubicell\/src\/OAMS\/AGT_MAIN_Verizon\/src\/ruby\

/insert.h>/g'


* '/' 문자의 경우 '\/'로 표현해야 하는 것을 주의할 것

'TIP' 카테고리의 다른 글

disfilever  (0) 2009.11.13
linux port 확인  (0) 2009.11.09
remove blank line   (0) 2009.09.17
cat /proc/meminfo  (0) 2009.09.03
ldd  (0) 2009.09.03