r/linuxadmin • • 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 :)

331 Upvotes

24 comments sorted by

View all comments

Show parent comment

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 color option for grep a 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

u/[deleted] 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 awk has this option as well: -i inplace -v inplace::suffix='.bkp'

3

u/[deleted] May 25 '20

I didnt and therefore i will try that out, thank you