常用脚本

格式化时间显示

date +%Y%m%d%H%M

查询动态库依赖

#!/bin/bash

file $1 2> /dev/null
readelf -d $1 2> /dev/null | grep Shared | awk '{print $5}'

检索函数依赖

#!/bin/bash

function read_dir(){
    for file in `ls $1`
    do
        if [ -d $1"/"$file ]
        then
            read_dir $1"/"$file $2
        else
            fileName=`echo  $1"/"$file | awk '/\.a/||/\.so/||/\.o/'`
            if [ -n "$fileName" ];then
                    result=`nm $fileName  2>/dev/null | awk '/'$2'/' |grep -E 'T\s'`
                    if [ -n "$result" ];then
                            echo $fileName
                    fi
            fi
        fi
    done
}

if [ $# -ne 2 ];then
        echo "usage: `basename $0` path funcName"
        exit -1
fi

read_dir $1 $2

生成tags文件

#!/bin/bash

ctags --languages=c,c++,asm --langmap=c:+.h --c-kinds=+p --extra=+q --fields=+iaS -R
find . -name '*.[chsS]' -print > cscope.files
cscope -b -q -k

你可能感兴趣的:(笔记)