Learn to Process Text in Linux Using Grep, Sed, and Awk
1–10 of 18 posts
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#2Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day and not be able to read it.
Are there people out there for whom these tools are daily drivers that are actually part of their core toolset, or are these mostly just hobbiest things where it feels neat to know. Like HAM radio operation.
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#3I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
If I'm going to use the tool multiple times - it lands in Python, gets checked in, might even get unit tests if I'm feeling energetic. But there are tons of times a day when I want to ask a question of a 5 GB text file that I can pound out in < 60 seconds with a bit of piped awk/sed/tr and some bash looping on the results).
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#4I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#5I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#6I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
So I always start with `cat filename | some tool`[1] and refine until the very moment that I think "damn, I can't remember how to do that with sed/awk/jq/xsv/..." and end my pipeline feeding into Python. There's no law against it! And on slow days I go back and figure out how I can do what I want with the other tools.
[1]: Yes, yes, UUOC[2], but I don't care!
[2]: https://groups.google.com/g/comp.unix.shell/c/532AcI3-zs4/m/...
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#7I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
It's important to realize that when you have gigabytes of data you need to analyze that you can go really fast this way. Python sure does have stuff like StringIO, but it just doesn't feel like the right kind of tool for that job. A ton of stuff is just columnar data like CSV or log files out there, and people have been using shell tools to process them for decades.
If you're having a hard time reading your complicated awk one liners, I suggest pretty printing it. [1] Plenty of people are using this in production by writing scripts in files.
[1] https://stackoverflow.com/questions/55745956/is-it-possible-...
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#8I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
Most of what my sed and awk programs I write aren't supposed to be maintainable, but rather typically one-off stuff for-the-moment sort of thing. I'll grant it's append-only code, but if I need to do the same thing later (or something adjacent) I'll typically just write another oneliner since there's no real effort involved in it.
It's pretty much always more effort to write an actual script in some language like python, since it needs to be in a file and have a name and take arguments and so on.
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#9I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
Re: Learn to Process Text in Linux Using Grep, Sed, and Awk
#10I feel like I have a weird relationship with these command line tools. They're obviously powerful, and grep in particular can be a huge time saver to be able to quickly process a file. Whenever I think Sed or Awk would be correct for a problem, I find myself with a clever 1 liner an hour later I look at and think "I should have just used python," as it's untestable / unmaintainable, and I'll come back the next day an…
sed ./target --file=