/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include int main(int argc, char** argv) { if (argc < 2) { warnln("usage: fgrep "); return 1; } for (;;) { char buf[4096]; auto* str = fgets(buf, sizeof(buf), stdin); if (str && strstr(str, argv[1])) write(1, buf, strlen(buf)); if (feof(stdin)) return 0; VERIFY(str); } }