Awk

http://www.linuxaria.com/article/6-trucchi-con-awk?lang=en

# Matches for stage1.kernelfire.com and caller and not caller10 in the first field; increments cnt and lastly print the first field concatenated with the cnt count tab, followed by the last field tab, followed by the field next to the last

$ awk '$1 ~ /stage1\.kernelfire\.com/ && $1 ~ /caller/ && ! /caller10/ {++cnt; field1=$1; field2=$(NF); field3=$(NF - 1); print(""field1""cnt" \t "field2" \t "field3"")}' filename.txt

Reference

http://blog.jpalardy.com/posts/skip-grep-use-awk/