ソースコードにはエラーコードが散在しています。grepを使用すると簡単に見つけることができますが、次の行に沿って出力を提供find_codeする(たとえばfind_code ####)実行できるbash関数が必要です。
/home/user/path/to/source.c
85     imagine this is code
86     this is more code
87     {
88         nicely indented
89         errorCode = 1111
90         that's the line that matched!
91         ok this block is ending
92     }
93 }現在私が持っているものは次のとおりです。
find_code()
{
    # "= " included to avoid matching unrelated number series
    # SRCDIR is environment variable, parent dir of all of projects
    FILENAME= grep -r "= ${1}" ${SRCDIR}
    echo ${FILENAME}
    grep -A5 -B5 -r "= ${1}" ${SRCDIR} | sed -e 's/.*\.c\[-:]//g'
}問題点:
1)これは行番号を提供しません
2).cソースファイルのみに一致します。.c、.cs、.cpp、およびその他のソースファイルに合わせてsedを取得するのに問題があります。ただし、Cを使用しているため、単に一致する-または:(コードの各行の前にファイル名にgrepが追加する文字)がobject->pointersすべて一致し、混乱します。
MATCH="= ${1}"。また--include=*.c --include=*.cpp --include=*.java --include=*.cs、検索をソースファイルに制限するために追加しました。ありがとう!