add filteruntil
Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
parent
82c8a6aaa1
commit
1c6cc5bb5e
2 changed files with 33 additions and 0 deletions
21
src/filteruntil.cpp
Normal file
21
src/filteruntil.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <iostream>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if(argc != 2) {
|
||||
std::cerr << "usage: " << argv[0] << " <pattern-string>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string pattern(argv[1]);
|
||||
std::string line;
|
||||
|
||||
while(std::getline(std::cin, line)) {
|
||||
if(line.find(pattern) != std::string::npos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while(std::getline(std::cin, line)) {
|
||||
std::cout << line << std::endl;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue