Find won't work in TextEdit

I opened a file in TextEdit. I saved it as Plain Text, but left it open. When I returned to edit the file again, it had "garbage" characters at the top and at the bottom. Instead of just closing the file without doing another save, I edited out the garbage then I saved and closed the file. When I opened the file again, it looked fine, but when I used the Find command in TextEdit, it doesn't find text I know is in the file. It almost as if it doesn't recognize the file as text. I dropped into a Terminal window and ran the Unix "file" command. It says the file is of type "data." My other .txt files are type "ASCII text." I tried cutting and pasting some of the text in the file to a new file and checked to see if it was searchable with Find. It's not. Is there any way I can make this file searchable again?

MacBook Pro, Mac OS X (10.6.7)

Posted on Jun 11, 2011 1:35 PM

Reply
8 replies

Jun 14, 2011 1:18 PM in response to sakinn

I discovered a way to restore the original (non-corrupt) version of my file. I dropped into a Terminal window and executed the following command:

tr -cd "\011\012\015[\040-\177]" < corrupt_filename.txt > good_filename.txt


This bascially says strip out all of the characters from the file named "corrupt_filename.txt" that aren't a tab (011), a line feed (012), a carriage return (015) or a printable ASCII character (040-177) and save the result to a file called "good_filename.txt".


The resulting file is of type "ASCII English text, with CR, LF line terminators" instead of "data" so it is again searchable in TextEdit.


Do a "man tr" in a Terminal window to see complete documentation for the tr command.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Find won't work in TextEdit

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.