finding string in very long file without newlines

What's the best way to find a string in a very long file without newlines in Unix? The standard utility I'm aware of for finding a string in a single file is grep, but for a long file without newlines, I think the output is just going to be the input. I suppose I could use sed to replace the string with another that catches my eye like "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA," and search for it visually, but with an extremely large file that would be impractical.

What if you just replaced the string with the original string + a newline?

If I try typing sed "s/string/string\n" filename, I'll get "\n" inserted everywhere I want the newline, but they'll be interpreted as a literal "\" and literal "n" by grep, not as newlines, so the file won't get broken into lines, and the grep output will be the entire file. Do you have another method for inserting newlines automatically. In a large file, manual insertions would be time consuming and probably inaccurate.

append newline after every 80 character as...

sed 's/\(.\{80\}\)/\1\n/g' inputfile

And that is not a literal \ and n, it is new line. Also if you wanted to see particular string instead of whole line as output, use -o option in grep.

grep -o 'string' file

This will surely work, but isn't

fmt -80 inputfile

a bit easier? After all, this was what "fmt" was designed for, no?

bakunin

When I tried fmt as shown above, the output is the input. But, the following works, breaking up the lines in test-d at occurrences of "sd" (> is a command prompt):
sed '
> s/sd/\
> /g' test-d >> test-d2

test-d2 will contain the broken lines.

Thanks for all you help.

---------- Post updated at 05:14 PM ---------- Previous update was at 04:37 PM ----------

Note to others with this problem: This solution seems to work in bash, not in tcsh, but maybe in other shells.