r/linuxadmin • u/ASIC_SP • May 23 '20
Learn to use grep/ripgrep/sed/awk one-liners with hundreds of examples
Hello!
Recently I published my ebook on GNU awk, which completes the trio of my books on GNU grep/sed/awk tools for cli text processing. I also included a chapter on ripgrep, because of its performance and features. You can use either of these links to get the bundle. Each book has a pdf and epub version.
The books are currently free to download, to help with quarantine learning.
You can view the book using these repos as well. The repo has markdown source, example/exercise files used in the book, list of changes between versions, etc.
Edit (Aug 2020): Solutions for the exercises have been added. You can also view the books online at:
I'd highly appreciate your feedback. I've tried to present features from the basics and build it step by step with plenty of examples. But a few things end up rushed or not explained well enough. Past feedback has helped me to improve some of these, so I hope you'd contribute as well.
Happy learning and stay safe :)
7
6
u/tekmologic May 23 '20
grep, awk, sed, tr have saved me weeks of manual work.
2 hours validation tests become 5 minute tests
6 hours text entry becomes 10 minutes of work
5
u/NetScr1be May 23 '20
Grabbed them and threw you US$3 without checking them.
I stuggled to teach myself awk (and a little sed) when a large part of my role read to analyse logs and transaction data.
Grep was any everyday thing that could always use some polish.
Thanks for doing this.
4
2
2
2
2
2
2
1
1
May 23 '20
Thanks for the heads-up; just purchased. It'll be nice to have some extra reading material during these quiet times.
0
May 23 '20
[deleted]
15
u/ASIC_SP May 23 '20
I wish I could go back in time and tell my 2008 self to learn sed/awk. It would have saved so much time for me. I worked in VLSI industry and my background in ECE didn't have lessons in Linux/cli. (But as a feedback, we did get it introduced to our juniors and I've been conducting workshops for them past 6 years or so)
Due to my nature of work, I had to do plenty of text processing which I managed between gvim and perl (only as script files, didn't even know it could be used via cli). I didn't know good resources to learn other than what my colleagues/seniors knew and my online searching skills weren't good either. I came to know about things like
coloroption forgrepa few years into my job during a series of learning sessions conducted by team members. Didn't know about stackoverflow/reddit/etc either. There were some internal documents which did have sed/awk but I gave up after cursory glance as too advanced/complicated.sed -i 's/old/new/g' <files>alone would have saved me lot of time instead of reusing perl scripts.2
May 24 '20
Once I found out awk could remove lines in file with ā awk '!/pattern/' file > temp && mv temp file ā it it saved me so much time or that you can do a backup of a file before modifying with sed by doing ā sed -i.backup.$(date) ās|old|new|gā
3
u/ASIC_SP May 25 '20
In case you don't know,
GNU awkhas this option as well:-i inplace -v inplace::suffix='.bkp'3
3
2
u/paganhobbit May 23 '20
Hey, thanks for this. I've wanted to find out more about SED and AWK, so I'm checking this out.
One thing, I think the EPUB versions aren't showing the example boxes correctly? They're just empty in the macos and iOS books app for me, anyway. I think the PDF versions are looking okay.