Circle Device


Quick Reference


AWK to Extract Section of a File

Extract a section of a file based on a start and end pattern, and do a little arithmetic:

/2019-01-11 10:02:2/{found=1;depth=50;wt=5}
/2019-01-11 10:04:0/{found=0}
/2019-01-11 10:04:1/{found=1;depth=100}
/2019-01-11 10:06:0/{found=0}
{if(found){d_diff_a=depth-$9;d_diff_b=depth-(($10+400)/4);print $0","depth","d_diff_a","d_diff_b","reading_no","wt;reading_no++}}

FS is field separator OFS is other field separator.

$10 refers to the 10th field in this file (in this example like the 10th column in a CSV).

Using AWK to Update DNS Records

Automating the creation of SSL certificates with Let's Encrypt for wildcard domain names. Using nsupdate would be nice but it would seem NSD does not support that and so I have a script that uses AWK to do some stuff...

Quick Links: Techie Stuff | General | Personal | Quick Reference