Using grep in a Macintosh text file

Hi,

I’d like to write a script that reads the content of a Macintosh text file and filters it based on a keyword.

grep -e “keyword” /Users/my_user/Desktop/testing.txt

doesn’t return the paragraphs that contain my keyword, it returns the full content of my testing.txt file. I believe the problem is caused by differences between Macintosh and UNIX regarding the carriage return (or line feed).

Is there an easy way to fix this?
:lol:

You can pass the text file through “strings” before handing it to grep.


cat Users/my_user/Desktop/testing.txt | strings | grep -e "keyword"

HTH -john

johnfountain,

Thank you for your reply.
I believe i found an easy way to convert a Macintosh text file to a UNIX text file.