Articles in Category "GNU/Linux"

Print all indented Lines following a non-indented Line

Some configuration and output text formats contain sections like the following: foo: value1 value2 bar: value 3 In this article, two scripts are presented that print all consecutive indented lines that follow a non-indented line that matches a search pattern given by a regular expression. This means, given the single argument foo and the standard […]

Maintaining Multi-Line „stat“ Formats using Bourne Again Shell

The stat command from GNU core utilities features not only a –format FORMAT option but also a –printf FORMAT one, the difference being that the latter allows for backslash escapes such as \n. This allows for custom per-file report formats containing newlines, for example: stat –printf ‚Name: %n\nSize: %s Bytes\n‘ /etc/passwd If the format string […]

Make a Bourne Again Shell Script Log its Output to a File

The Bourne Again Shell script presented in this article demonstrates techniques related to capturing and logging output (standard output and standard error stream) of a script into a log file while also delivering it to the regular output destinations (for example the terminal or whatever the caller has chosen to redirect to). If you are […]

Using sed or awk to ensure a specific last Line in a Text

Given a file containing bytes of text with lines separated by the newline character (\n), one of these lines can be said to be „the last line of the file“; it is a sequence of bytes occurring in the file, for which holds: The sequence contains no newline character, and the sequence is followed by […]

I went to CLT23 …

… and i got a new coffee mug. 🙂

Determine IPv4 Addresses of a Libvirt Qemu-KVM Domain

In the VM, on Redhat-likes, make sure that the Qemu guest agent is installed: dnf install qemu-guest-agent On Debian-likes, execute: apt install qemu-guest-agent For Microsoft Windows guests, there are some tutorials on the web, see for example [1]. On the HV, execute: virsh qemu-agent-command –domain myvm \ ‚{„execute“:“guest-network-get-interfaces“}‘ | \ jq -r ‚ [.return[] | […]

Removing the Builtin Inline CSS from WordPress

Should you – as i did – wonder why WordPress renders a bucket of inline CSS into the HTML output (such as –wp–preset–font-size–normal in <html> or  –wp–preset–color–white in <body>): This is done to accomodate frontend editing with Gutenberg. If you – as i do – are not using Gutenberg frontend editing, then the following PHP […]

Updated Common Prefix Notation Transformation

This is an update to my previous article on determining the common prefixes of a set of strings (passed a sequence of lines) and printing them in common prefix notation (CPN). The problem of reconstructing strings from the original input that are complete prefixes of other input strings is addressed. The code is now in […]