Using SED and AWK to remove/replace substrings

Again, when we need to remove a pesky character or remove sections of strings upon occurrence, we can always rely on these two powerful commands: sed and awk. And while we saw that Bash does indeed have a similar functionality built-in, the full tools are able to offer the same and more complex functionality. So, when should we use these tools?

  • When we care less about the speed that might be gained by using the built-in functionality of Bash
  • When more complex features are needed (when programming constructs like multi-dimensional arrays are required or editing streams)
  • When we are focused on portability (Bash might be embedded or a limited version and standalone tools may be required)
Complete ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.