During post-exploitation log review, you notice 32-character hexadecimal hashes scattered through a web-server log mixed with irrelevant noise. You need a single command-line utility that can
substitute every hash with the token [HASH], and
delete any line that does not contain the word accepted, all in one pass without writing a separate script. Which Unix tool is purpose-built for this kind of inline stream editing?
sed (stream editor) lets you combine multiple editing commands-such as a global substitution (s/[A-Fa-f0-9]\{32\}/[HASH]/g) and a deletion (/accepted/!d)-in a single invocation. awk could accomplish the task but typically requires a longer program block; grep only filters, and tr can translate or delete individual characters but cannot apply regex substitutions and conditional line removal together.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
How does the regex `s/[A-Fa-f0-9]\{32\}/[HASH]/g` work in sed?
Open an interactive chat with Bash
What does the command `/accepted/!d` do in sed?
Open an interactive chat with Bash
Why is sed a better tool for this task than awk, grep, or tr?