with grep, to show only line number and string on the line: grep -n "[string_to_search]" [filename] |cut -f1,2 -d: