Another Word For It Patrick Durusau on Topic Maps and Semantic Diversity

March 4, 2016

You Can Master the Z Shell (Pointer to How-To)

Filed under: Awk,Linux OS,Shell Scripting — Patrick Durusau @ 4:31 pm

Cutting through the toxic atmosphere created by governments around the world requires the sharpest tools and develop of skills at using them.

Unix shells are like a switchblade knife. Not for every job but if you need immediate results, its hard to beat. While you are opening an application, loading files, finding appropriate settings, etc., a quick shell command can have you on your way.

Nacho Caballero writes in Master Your Z Shell with These Outrageously Useful Tips:

If you had previously installed Zsh but never got around to exploring all of its magic features, this post is for you.

If you never thought of using a different shell than the one that came by default when you got your computer, I recommend you go out and check the Z shell. Here are some Linux guides that explain how to install it and set it as your default shell. You probably have Zsh installed you are on a Mac, but there’s nothing like the warm fuzzy feeling of running the latest version (here’s a way to upgrade using Homebrew).

The Zsh manual is a daunting beast. Just the chapter on expansions has 32 subsections. Forget about memorizing this madness in one sitting. Instead, we’ll focus on understanding a few useful concepts, and referencing the manual for additional help.

The three main sections of this post are file picking, variable transformations, and magic tabbing. If you’re pressed for time, read the beginning of each one, and come back later to soak up the details (make sure you stick around for the bonus tips at the end). (emphasis in original)

Would be authors/editors, want to try your hand at the chapter on expansions? Looking at the documentation for Zsh version 5.2, released December 2, 2015, there are 25 numbered subsections for 14 Expansion.

You will be impressed by the number of modifiers/operators available. If you do write a manual for expansions in Zsh, do distribute it widely.

I hope it doesn’t get overlooked by including it here but Nacho also wrote: AWK GTF! How to Analyze a Transcriptome Like a Pro – Part 1 (2 and 3). Awk is another switchblade like tool for your toolkit.

I first saw this in a tweet by Christophe Lalanne.

August 27, 2014

Unofficial Bash Strict Mode

Filed under: Bash,Shell Scripting — Patrick Durusau @ 7:26 pm

Use the Unofficial Bash Strict Mode (Unless You Looove Debugging) by Aaron Maxwell.

Let’s start with the punchline. Your bash scripts will be more robust, reliable and maintainable if you start them like this:

#!/bin/bash
set -euo pipefail
IFS=$'\n\t' 

I call this the unofficial bash strict mode. This causes bash to behave in a way that makes many classes of subtle bugs impossible. You’ll spend much less time debugging, and also avoid having unexpected complications in production.

There is a short-term downside: these settings make certain common bash idioms harder to work with. They all have simple workarounds, detailed below: jump to Issues & Solutions. But first, let’s look at what these obscure lines actually do.

The sort of thing you only hear about in rumors or stumble across in a Twitter feed.

Bookmark and share!

I first saw this in a tweet by Neil Saunders.

July 26, 2011

Using Tools You Already Have

Filed under: Data Analysis,Shell Scripting — Patrick Durusau @ 6:22 pm

Using Tools You Already Have

A useful post on why every data scientist should know something about bash scripting.

Powered by WordPress