Re:Learn to Process Text in Linux Using Grep, Sed, and Awk
by 1vuio0pswjnm7 on Saturday January 07, 2023 @08:22PM
(#34294997)
Here are a couple more, edited for HN of course. These are scripts/snippets that would often be used in or by other scripts. Each illustrates some basic quick and dirty usage of tr, sed and grep. These scripts will last for many years with zero "maintenance". They will probably still be working after I have passed away. It seems that python scripts OTOH may have a shelf life.
Task 1: Transform the BIND format of stub resolver output, i.e., the format used by "dig" and many other stub resolvers, to some other format, like HOSTS file, BIND/tinydns zone file, haproxy map file, etc. The input would typically be catenated stub resolver output for hundreds to thousands of domains. The epoch program is three lines of C.
NB. For large input on Linux, dash is significantly faster than bash. I wrote a C program that does the job of this script, faster than dash, and much faster than python. However I still prefer the shell for testing ideas, quickly.
Task 1: Transform the BIND format of stub resolver output, i.e., the format used by "dig" and many other stub resolvers, to some other format, like HOSTS file, BIND/tinydns zone file, haproxy map file, etc. The input would typically be catenated stub resolver output for hundreds to thousands of domains. The epoch program is three lines of C.
NB. For large input on Linux, dash is significantly faster than bash. I wrote a C program that does the job of this script, faster than dash, and much faster than python. However I still prefer the shell for testing ideas, quickly.
For example, Task 2: Extract and transform CloudFront domains and their CNAMEs from BIND format stub resolver output to haproxy map format. For example,