mnr
mnr

Reputation: 634

Grab text from a text file using Bash

I have a large source code file, I would like to split it into many smaller files.

For this, I would like to insert in the original source code file, certain start line (e.g., ##START) and certain end line (e.g., s##END).

Is there some linux command that searches and then grabs the text between ##START and ##END and output it to stdout?

Upvotes: 2

Views: 199

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207455

If you want it easy to remember how to see the "juicy" parts of a file, define a function in your login profile based on @oguzismsail's comment, like this:

juicy(){ sed -n '/##START/,/##END/p' "$1"; }

Then you can just run:

juicy SomeFile.txt

Upvotes: 3

Related Questions