You can replace text using commands like sed or awk with the s/regex/replacement/ syntax, where regex is the pattern to match and replacement is the text to replace it with.