๐Ÿ“š General & Other

Excluding Multiple Prefixes in a Single Pass

removes one prefix. Chaining a dozen calls to remove a dozen prefixes rereads the input a dozen times.

grep -v '^/admin/' removes one prefix. Chaining a dozen grep calls to remove a dozen prefixes rereads the input a dozen times.

One pass with a pattern file

grep -v -f prefixes.txt input.txt reads the patterns from a file and applies them all in a single pass. Add -F if they are literal strings rather than expressions โ€” the combination is both faster and immune to metacharacters in the prefixes.

Alternation as the alternative

grep -vE '^(/admin/|/login/|/tmp/)' does the same in one expression. Readable at three prefixes, unmaintainable at thirty, and the pattern file scales better.

Escaping matters in a pattern file too

Without -F, each line of the file is a regular expression. A prefix containing . or + behaves as a pattern, which usually still matches what you wanted and occasionally matches more. Use -F unless you specifically need patterns.

Try it: Remove Lines Starting With on SeoWolf's Notepad.