this post was submitted on 23 Jun 2023
6 points (100.0% liked)

Linux

114 readers
1 users here now

founded 1 year ago
 

Linux is known for its flexibility and customization options, and there are countless tools and commands available for users to explore. However, two of the most versatile and powerful tools that every Linux geek should know are sed and awk. These command-line tools have been around for decades and are still widely used by system administrators, programmers, and power users alike. In this article, we’ll explore why every Linux geek needs to know these two tools. First, let’s define what sed and awk are. Sed (short for “stream editor”) is a command-line tool that is used for performing simple text […]

top 6 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago

Sed is useful to understand linuxmasterrace jokes.

[–] [email protected] 2 points 1 year ago (1 children)

I dunno. I've been running *nix boxes since the 90s and only used sed and awk a handful of times. A handful as in 3-5. It just depends what you do.

[–] [email protected] 2 points 1 year ago

I’m a macOS admin and I use sed fairly frequently in scripts. Can’t say I’ve had many uses for it or awk as a Linux user, however.

[–] [email protected] 2 points 1 year ago

Wanna see something that makes even Perl look elegant and readable? Check out any sed script. Here's tetris, in sed: https://github.com/uuner/sedtris/blob/master/sedtris.sed

[–] [email protected] 1 points 1 year ago (1 children)

I'll probably need a few more lines in Python, but I can do everything i want and don't have to deal with the cryptic syntax. I once had to use awk because some extra pigheaded sysadmin refused to install Python on an AIX machine. Glad i don't work there any more.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Python isn't really a fantastic drop-in replacement for them, IMHO, though there is some overlap.

There are a bunch of Unix tools that let one concisely put a lot of logic into a single command line. They lower the bar to throwing a lot of logic into that single line.

Python's whitespace-sensitive and requires newlines. I guess theoretically you could use a HEREDOC or something, but realistically, if you use Python, you're going to go author a throwaway script and then execute it, which raises the bar to just including it in your command lines.

I think that Perl is probably closer to a middle ground between "application-oriented programming languages" and "single command line use". I think that it'd be reasonable to simply use perl -pie as an alternative to awk especially, though having sed's conciseness is still nice.

load more comments
view more: next ›