I received a .txt file with tab-delimited fields. The file contains 65K-plus records.

I want to edit the file, removing some records. Specifically, I want to find all records that contain a particular word--let's say "taffy"--in any of its fields. The field may--or may not--begin with "taffy", it may be the 2nd or 3rd word in a field.

I have imported this .txt file in Apple Numbers as a spreadsheet, but am happy to use a database app (that's free or cheap) to do this.

The end result will be used as a simple look-up table and can be either a spreadsheet or database file.

What app will allow me to search this file and group records according to the results (containing "taffy" in one of the fields) so that they can be multiple-selected and deleted?

Maybe I'm looking for an app that allows use of Boolean or Regular Expressions in its search function? And can group records according to the search results.


  • try google spreadsheet – gamer0 Jul 7 '19 at 18:01

Start a Terminal and use the command grep to filter the lines not containing "Taffy", like this:

grep --invert --no-filename taffy input_file.txt > output_file.txt

This gives you a new file (output_file.txt) without the lines containing taffy.

Another usefully option might be the --ignore-case option.


  • --invert selects the lines not containing the search expression
  • --no-filename suppresses the filename as part of the output
  • --ignore-case ignores the case of the search string; Taffy, tAfFy, taffy and TAFFY all match.
  • the > redirects the output of the command to a file.
| improve this answer | |
  • Thanks agto! It seems to do exactly what I need. Now since the file contains more records (2 million-plus) than 1 spreadsheet can hold, I need to break up the file (breaking at paragraph markers) into 3 files so I can spread them across 3 sheets. How can I do that in Terminal? Thanks again! – DaveC Jun 25 '19 at 3:45
  • Use the split command: split -l 500000 file.txt splits the file in subfiles of 500.000 lines. See the man page for more info. – agtoever Jun 25 '19 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.