I have a file that possibly contains bad formatting (in this case, the occurrence of the pattern \\\\backslash). I would like to use grep to return
\\\\backslash
grep
You're going to want the second field after the colon, not the first.
grep -n "text to find" file.txt | cut -f2 -d:
Bash version
lineno=$(grep -n "pattern" filename) lineno=${lineno%%:*}