| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| Hello again, There is another thing about sed that I could not figure out yet. I would like to know how many lines of the original file are effected by changes. I have done this so far by retrieving the line numbers of those lines that match an expression - and then counted the line numbers in C++. However, this seems to slow everything so much down, that I removed this function. But it would still be nice to know how many lines were effected. So is there a way to give sed a expression and ask for the number of lines that match this expression? Thanks for any help, Oliver |
|
#2
|
| On Tuesday 26 August 2008 22:24, Oliver Witt wrote: > So is there a way to give sed a expression and ask for the number of > lines that match this expression? Sure, but it's *a lot* saner to use grep -c for that. There are various grep ports for windows. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |
|
#3
|
| On Aug 26, 10:24*pm, Oliver Witt > Hello again, > > There is another thing about sed that I could not figure out yet. > > I would like to know how many lines of the original file are effected > by changes. I have done this so far by retrieving the line numbers of > those lines that match an expression - and then counted the line > numbers in C++. However, this seems to slow everything so much down, > that I removed this function. But it would still be nice to know how > many lines were effected. > > So is there a way to give sed a expression and ask for the number of > lines that match this expression? > > Thanks for any help, > > Oliver The wc utility can be used for counting the number of lines from the standard output. sed -n '/my-regexp/p' my-file | wc -l |
![]() |
| Thread Tools | |
| Display Modes | |