我正在使用 grep 创建 shell 脚本来跟踪日志

我正在使用 grep 创建 shell 脚本来跟踪日志

而不是打印出来,

============ Normal grep location of the files ============
ems_inet1/SystemOut1.log
ems_rpt1/SystemOut_19.09.09_23.00.00.log
ems_rpt1/SystemOut_19.09.11_23.00.00.log
============ Compress grep location of the files ============
ems_rpt1/SystemOut_19.05.12_23.00.00.log.gz

我想打印这个,

============ Normal grep location of the files ============
ems_inet1 - SystemOut1.log
ems_rpt1 - SystemOut_19.09.09_23.00.00.log
ems_rpt1 - SystemOut_19.09.11_23.00.00.log
============ Compress grep location of the files ============
ems_rpt1 - SystemOut_19.05.12_23.00.00.log.gz

我不想有斜杠,我想用“-”破折号分隔它

这是我的代码

echo "============ Normal grep location of the files ============"
grep -Erl "${input}" ems*/SystemOut*.log
#
echo "============ Compress grep location of the files ============"
zgrep -Erl "${input}" ems*/SystemOut*.log.gz

答案1

grep -Erl "${input}" ems*/SystemOut*.log | sed 's#/# - #'

相关内容