15622Re: Selective portion of a file
- Jul 1, 2003
On 11:13 01 Jul 2003, p_s_rathi <p_s_rathi@...> wrote:
| Yeah thats true,
| but it will display all occurences of particular string in file.
| Is it possible to display whole function's code(suppose the code of
| main() in .c file)? any command for that?or any good editor which
| will save time for it.
Well, if you know a little about your code formatting convention you can
sed -n '/^main(/,/^}/p' foo.c
which assumes "main(" will be at the start of a line and that the next
closing } which is also at the start of a line is the end of the function.
sed -n '/starting-marker/,/ending-marker/p' filename...
will do what you ask. You just have to pick suitable starting-marker and
Extremely handy. Cheers,
Cameron Simpson <cs@...> DoD#743
Thus spake Kalmoth the Avenger, Kinsman of the Slain:
"DISCLAIMER: I speak for no one who lives."
- << Previous post in topic