This is the most trivial example of a `grep` I could write using Qt. All it does is read line by line, apply a `QRegularExpression` and prints any matching line. ```plaintext #include #include #include #include // args are: // pattern file1 [file2 ...] // if file1 not specified, use stdin QTextStream& qStdOut() { static QTextStream ts( stdout ); return ts; } QTextStream& qStdErr() { static QTextStream ts( stderr ); return ts; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDir dir; qStdOut() << dir.currentPath() << "\n"; qStdOut().flush(); if( argc < 3 ) { qStdOut() << "pmgrep \n"; qStdOut().flush(); } else { // take pattern from argv[1] // iterate over args from 2 onwards const char* pattern = argv[1]; const QRegularExpression regular_expression(pattern); for(int i=2; i