sew and awk - what are those?

sed and awk are two powerful command-line tools for text processing in Linux. They can both read text files or input streams line by line and perform operations on them using regular expressions. However, they have different features and capabilities.

sed stands for “stream editor”. It is designed to make changes to a stream of text, such as deleting, inserting, replacing, or transforming text. It has a simple and compact syntax that consists of commands that specify a pattern to match and an action to perform on the matched text. For example, the following command will replace all occurrences of “foo” with “bar” in a file:

sed 's/foo/bar/g' file.txt

awk is a programming language for text processing and manipulation. It is more powerful and versatile than sed, as it allows writing effective programs in the form of statements that can perform comparison, arithmetic, logical, and string operations on the extracted text. It also has built-in variables and functions that can handle common tasks such as counting, formatting, sorting, etc. For example, the following program will print the sum of the second column of a file:

awk '{sum += $2} END {print sum}' file.txt

Both sed and awk are useful tools for working with text data, but they have different strengths and weaknesses. sed is simpler and easier to use for basic text editing tasks, while awk is more suitable for complex text processing that requires more logic and control.

Should you still use sed and awk?

sed and awk are two classic command-line tools for text processing. They have been around for decades and are widely used by Unix and Linux users.

Pros of using sed and awk:

  • They are fast and efficient. sed and awk are written in C and optimized for performance. They can handle large files and complex operations without much overhead. They are also portable and available on almost any Unix-like system.
  • They are simple and elegant. sed and awk have a concise and expressive syntax that makes them easy to learn and use. They follow the Unix philosophy of doing one thing well and composing well with other tools. They can be used as filters, generators, or transformers of text data.
  • They are versatile and powerful. sed and awk can perform a wide range of text processing tasks, such as searching, replacing, extracting, formatting, parsing, or manipulating text data. They can also handle regular expressions, variables, arrays, functions, and control structures.

Cons of using sed and awk:

  • They are old and outdated. sed and awk were designed in the 1970s and 1980s, when text processing was simpler and less diverse. They have not evolved much since then and lack some modern features, such as Unicode support, JSON parsing, XML processing, or web scraping.
  • They are cryptic and obscure. sed and awk have a terse and arcane syntax that makes them hard to read and maintain. They also have some quirks and limitations that can cause unexpected results or errors. For example, sed does not support multi-line patterns, while awk has different versions with different behaviors.
  • They are isolated and incompatible. sed and awk are not well integrated with other tools or languages. They have their own syntax, data structures, and conventions that make them difficult to combine or extend. They also have different implementations that may not be compatible with each other or with the current standards.


sed and awk are still useful tools for text processing, but they are not the only ones. Depending on your needs and preferences, you may find other tools or languages more suitable or convenient for your tasks. For example, you may use Perl, Python, Ruby, or JavaScript for more complex or modern text processing tasks, or you may use Vim, Emacs, Sublime Text, or VS Code for more interactive experience

However, this does not mean that you should abandon sed and awk altogether. They are still valuable skills to have as a Unix or Linux user, and they can still solve many problems quickly and elegantly. You may also find them handy for prototyping, testing, or debugging your text processing scripts or programs.

Ultimately, the choice is yours. You should use the tools that work best for you and your situation. There is no definitive answer to whether you should still use sed and awk or not. It depends on what you want to do with them.

To contact me, send an email anytime or leave a comment below.