$ cat data trk 1 soft trk 1 get trk 1 get trk 1 soft $ awk '/soft/ { print "this", NR, "that" }' data this 1 that this 4 that $