【发布时间】:2014-08-07 18:07:04
【问题描述】:
我使用 grep 从出现特定字符串的文件中获取行号。如果我希望这些行号出现在由逗号分隔的行中而不是垂直行中怎么办?
cFont=$(grep -icE "<font *" $htmlFile)
if [ $cFont -gt 0 ] ; then
echo "There are $cFont line(s) with <font> tag, they are: " >> ~/Desktop/errors.txt
grep -inE "<font *" $htmlFile |cut -f1 -d: >> ~/Desktop/errors.txt
fi
结果是
There are 4 line(s) with <font> tag, they are:
14
43
46
72
我希望它是
There are 4 line(s) with <font> tag, they are:
14, 43, 46, 72
【问题讨论】: