Using entr to get immediate test feedback

Old and new workflows My dev workflow used to look like this: Write some code and save it Change to my Terminal window Up-arrow to find my command to run unit tests (typically make test) Press Enter Wait for tests to run and examine test output This worked pretty well, but was a lot of manual steps when you figure that I did this dozens (hundreds?) of times per day. That’s a lot of energy spent doing the same thing over and over again....

2022-09-07

Line beaks in file names on Linux

Today I accidentally created a file whose name had a newline character in it. I didn’t notice it when I did it, but here’s how it showed up in my shell. There was a directory whose name shared the first few characters of the filename. [22:07] james_simas@widget /var/tmp $ ls o* oops? <--- Suspicious file! oops: <--- Directory I tried to delete it: [22:07] james_simas@widget /var/tmp $ rm 'oops?' rm: oops?...

2021-02-02

Operating on a subset of lines with sed

Today a coworker posed an interesting question to me. Given a BIG-IP configuration file with thousands of records like this… gtm pool /Common/p_example { members { /Common/2001:668:fc78:0:f811:3ef2:fed7:98cc:vs6_2001_668_fc78_0_f811-3ef2-fed7_98cc-80 { order 0 } } monitor /Common/gateway_icmp } …how can we easily replace every colon in the name : with \\:? In short, /Common/2001:668:fc78:0:f811:3ef2:fed7:98cc:vs6_2001_668_fc78_0_f811-3ef2-fed7_98cc-80 needed to become /Common/2001\\:668\\:fc78\\:0\\:f811\\:3ef2\\:fed7\\:98cc\\:vs6_2001_668_fc78_0_f811-3ef2-fed7_98cc-80. This must only be done on the lines with start with /Common and which also contain the string vs6....

2019-09-11

Notes on sed

I’ve always been a bit hit-or-miss with sed and haven’t understood it to the level to which I wanted. Today I aimed to change that and these are my notes from sitting down to learn it. Replace a string in a file (first occurrence per line only): cat file.txt | sed 's/oldstring/newstring/' Replace a string in a file (all occurrences per line, i.e., globally): cat file.txt | sed 's/oldstring/newstring/g' Use your own delimiters by just dropping them in place of /:...

2019-06-15