Search code examples
stringtodo

Retrieve "TODO" lines from a text file


I'm editing a project in GEdit (text editor). When I type TODO it highlights it yellow for future reference. I have quite a few of these TODOs around the place.

To make it clearer what I need to do, can anyone show me a way to extract any TODO lines from a bunch of files and put them into one text file called, for example, TODOs.txt?

I have something like this:

// TODO: Error handling.

And want it to be put in a file like this:

* <file name> <line number> Error handling

A Linux application (CLI, GUI don't mind) would be preferable, but a regex script or another method someone could come up with would be cool.


Solution

  • try grep TODO -rnf * > TODOs.txt