?? chgipath.sh
字號:
#!/bin/sh## $Log: chgipath.sh,v $# Revision 1.5 2002/07/11 21:28:14 meister# add pass through AWK to work around SED pattern buffer "feature"# which drops lines not ending with NL## Revision 1.4 2002/04/09 15:51:26 meister# use a slightly better regexp to exclude, say, #include's inside quotes or# comments, and allow for funny spacing such as## #ifdef FROBS# # include <frobs.h># #endif## Revision 1.3 2002/04/08 21:23:11 meister# remove a few debugging messages## Revision 1.2 2002/04/08 20:41:24 meister# fix install.h path## Revision 1.1 2002/04/06 00:48:04 meister# shell script to edit old-directory-layout include paths##SEDSCR=tmp_sed.$$CreateSedScript (){cat > $SEDSCR 0<<EOF /^[ \t]*#[ \t]*include[ \t]*<.*>/s/<attache\/h/<wrn\/wm\/attache/g/^[ \t]*#[ \t]*include[ \t]*<.*>/s/<common\/h/<wrn\/wm\/util\/common/g/^[ \t]*#[ \t]*include[ \t]*<.*>/s/<envoy\/h/<wrn\/wm\/snmp\/engine/g/^[ \t]*#[ \t]*include[ \t]*<.*>/s/<layout\/h/<wrn\/wm\/util\/layout/g/^[ \t]*#[ \t]*include[ \t]*<.*>/s/<snark\/h/<wrn\/wm\/demo/g/^[ \t]*#[ \t]*include[ \t]*<.*>/s/<install.h/<wrn\/wm\/util\/common\/install.h/gEOF}RmSedScript (){ rm -f ${SEDSCR}}SedIncludes (){ if [ -d ${1} ]; then if [ "${RECURSE}" = "yes" ]; then echo "entering directory ${1}" cd ${1} CreateSedScript for I in * do SedIncludes ${I} done RmSedScript echo "exiting directory ${1}" cd .. fi fi if [ -f ${1} ]; then for I in ${FILE_TYPES} do case ${1} in *${I}) echo "editing ${1}" if [ "${SAVEOLD}" = "yes" ]; then mv ${1} ${1}.old awk '{ print $0 }' < ${1}.old | sed -f ${SEDSCR} > ${1} else awk '{ print $0 }' < ${1} \ | sed -f ${SEDSCR} > ${1}.tmp mv ${1}.tmp ${1} fi ;; *) ;; esac done fi}### Main script starts here##RECURSE="no"SAVEOLD="no"if [ "X${SUFFIXES}" = "X" ]; then FILE_TYPES=".c .h"else FILE_TYPES=${SUFFIXES}fiif [ X${1} = "X" ]; then echo "Usage: chgipath [-r] [-s] <file1/dir1> [<file2/dir2> ...]" echo "If '-r' is given, chgipath will recursively process directories" echo "left with a '.old' suffix appended." exit 255fiCreateSedScriptfor I in $*do case $I in -r) RECURSE=yes ;; -s) SAVEOLD=yes ;; *) SedIncludes $I ;; esacdoneRmSedScript
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -