我编写了以下脚本来从日志文件中挑选关键字并突出显示术语:
#!/bin/bash
case "$1" in
*.log) sed -e "s/\(.*\[Error\ \].*\)/\x1B[31m&\x1b[0m/" "$1" \
| sed -e "s/\(.*\[Warn\ \ \].*\)/\x1B[33m&\x1b[0m/" \
| sed -e "s/\(.*\[Info\ \ \].*\)/\x1B[32m&\x1b[0m/" \
| sed -e "s/\(.*\[Debug\ \].*\)/\x1B[32m&\x1b[0m/"
;;
esac
它工作正常,直到我尝试跟随/减少尾随(Shift+F),此时它无法尾随任何新的日志行。任何想法为什么?