2011-9-23
sed命令用法参考资料:http://www.linuxsir.org/bbs/showthread.php?t=189620,http://jiebaiyou.blog.163.com/blog/static/11624901820094201479719/
$ sed '/test/{ n; s/aa/bb/; }' example-----如果test被匹配,则移动到匹配行的下一行,替换这一行的aa,变为bb,并打印该行,然后继续。
zhyfly@zhyfly:~/bash$ echo "hello\hh\haha"|sed -e 's/\\/'"'"'/g'hello'hh'haha
xgy@ubuntu:~/tmp$ cat sedtest
dgklsdfdald
dfjektestkl
kdfeoweqe
aa j il
xgy@ubuntu:~/tmp$ sed '/test/{n;s/aa/bb/;}' sedtest
dgklsdfdald
dfjektestkl
kdfeoweqe
aa j il
xgy@ubuntu:~/tmp$ sed '/test/{n;s/eow/bb/;}' sedtest
dgklsdfdald
dfjektestkl
kdfbbeqe
aa j il
gcc -dumpspecs | sed \
-e 's@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' \
-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
-e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \
`dirname $(gcc --print-libgcc-file-name)`/specs
上面命令的意思:
s@/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g':将/tools/lib/ld-linux.so.2换为/lib/ld-linux.so.2,
'/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/@}'如果匹配*startfile_prefix_spec:则将下一行的.*换为/usr/lib/
/\*cpp:/{n;s@$@ -isystem/usr/include@}:如查匹配*cpp:,则将下一行的$换为:-isystem /usr/include
sed -i's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
libiberty/将Makefile文件中的/install_to_$(INSTALL_DEST)去掉
sed -i's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in
将gcc/Makefile.in文件中行首的XCFLAGS =$换为XCFLAGS =$-fomit-frame-pointer
sed -i's@\./fixinc\.sh@-c true@' gcc/Makefile.in
将gcc/Makefile.in文件中的./fixinc.sh换为-c true
sed -i's/@have_mktemp_command@/yes/' gcc/gccbug.in
将gcc/gccbug.in文件中的have_mktemp_command换为yes