Friday, February 05, 2021

Learn To Love the Command Line

I've used UNIX- and Linux-based systems almost from the beginning of my technical writing career and have developed a bit of skill with the command shell. It was especially useful navigating the dozens of command scripts that I had to document at the TSX and especially when working with logs of error messages that could be thousands of lines long. 

Although many technical writers shun the command line as an archaic relic, there are some things that you just can't do easily with a GUI-based tool, even one that has a macro programming capability. This article from Nature is aimed at scientific researchers, who often have to work with huge data sets, but can apply equally well to writers who have to work with similar kinds of files on a smaller scale. 

Prebuilt into macOS and Unix systems, and available on Windows through such tools as the free ‘Windows Subsystem for Linux’ and MobaXterm, the command line (also called the shell) is a powerful text-based interface in which users issue terse instructions to create, find, sort and manipulate files, all without using the mouse. There are actually several distinct (although largely compatible) shell systems, among the most popular of which is Bash, an acronym for the ‘Bourne again shell’ (a reference to the Bourne shell, which it replaced in 1989).

Bash is both a collection of small utilities and a full-blown programming language, ranging from ‘grep’, a powerful text-search tool, to ‘for loops’, which allows users to repeat actions across multiple files. Johnson directed her terminal to scan her hard disk for sequencing data files, extract the needed information and compile them into a tidy spreadsheet. “That took me less than 10 minutes,” she says; recomputing the data would have taken a full day.

Many computational disciplines, such as bioinformatics, rely heavily on the command line. But all researchers who use computers can benefit from it, says Jeroen Janssens, principal instructor of Data Science Workshops in Rotterdam, the Netherlands, and author of the 2014 book Data Science at the Command Line. “The mouse doesn’t scale,” Janssens explains. For instance, although it is certainly possible to rename a file by pointing and clicking, that task becomes tedious when it is scaled to hundreds or thousands of files.

As the article points out, even Windows users can access the command shell. At the TSX, I used Cygwin, but newer Windows systems now have Linux integration using the Windows Subsystem for Linux. The native Windows Powershell tool is also quite powerful, although it uses a different syntax than the venerable BASH Linux shell.  

No comments: