我的描述很新。 我正试图写一个文字,以检查错误的日志(手法硬编码),我必须印刷含有错误的文字。 i 能够书写逻辑,但需要点人阅读用户投入文件。
Appreciate the help thanks.
Logic:
- Accept the logfile patch from user
- Check if the logfile is present or not
- If present search the file for lines containing the error string (eg. Error, ORA)
- Print the lines containing error strings , also write the output to a logfile
阅读用户的日志
3. 错误指示
search="ERROR"
set a path for output file
outfile="file1.txt"
Execution logic
find "$mydir" -type f -name "$filename" |while read file
do
RESULT=$(grep "$search" "$file")
if [[ ! -z $RESULT ]]
then
echo "Error(s) in $file: $RESULT" >> "$outfile"
fi
done