HOW-TOs

Text Processing in Rust

Create handy command-line utilities in Rust. This article is about text processing in Rust, but it also contains a quick introduction to pattern matching, which can be very handy when working with text. Strings are a huge subject in Rust, which can be easily realized by the fact that Rust has two data types for representing strings as well as support for macros for formatting strings. However, all of this also proves how powerful Rust is in string and text processing.

Easier Python paths with pathlib

A look at the benefits of using pathlib, the "object-oriented way of dealing with paths". Working with files is one of the most common things developers do. After all, you often want to read from files (to read information saved by other users, sessions or programs) or write to files (to record data for other users, sessions or programs).

Command-Line Tip: Put Down the Pipe

Learn a few techniques for avoiding the pipe and making your command-line commands more efficient. Anyone who uses the command line would acknowledge how powerful the pipe is. Because of the pipe, you can take the output from one command and feed it to another command as input. What's more, you can chain one command after another until you have exactly the output you want.

Back to Basics: Sort and Uniq

Learn the fundamentals of sorting and de-duplicating text on the command line. If you've been using the command line for a long time, it's easy to take the commands you use every day for granted. But, if you're new to the Linux command line, there are several commands that make your life easier that you may not stumble upon automatically. In this article, I cover the basics of two commands that are essential in anyone's arsenal: sort and uniq.

More Roman Numerals and Bash

When in Rome: finishing the Roman numeral converter script. In my last article, I started digging in to a classic computer science puzzle: converting Roman numerals to Arabic numerals. First off, it more accurately should be called Hindu-Arabic, and it's worth mentioning that it's believed to have been invented somewhere between the first and fourth century—a counting system based on 0..9 values.

Testing Your Code with Python's pytest, Part II

Testing functions isn't hard, but how do you test user input and output? In my last article, I started looking at "pytest", a framework for testing Python programs that's really changed the way I look at testing. For the first time, I really feel like testing is something I can and should do on a regular basis; pytest makes things so easy and straightforward.

Roman Numerals and Bash

Fun with retro-coding a Roman numeral converter—I head back to my college years and solve me homework anew! I earned a bachelor's degree in computer science back in the dawn of computing. Well, maybe it wasn't quite that long ago, but we did talk about Ada and FORTRAN in class. As a UCSD alumnus, however, it's no surprise that UCSD Pascal was the programming language of choice. Don't worry; no punch cards and no paper tape were involved in my educational endeavors.

Schedule One-Time Commands with the UNIX at Tool

Cron is nice and all, but don't forget about its cousin at. When I first started using Linux, it was like being tossed into the deep end of the UNIX pool. You were expected to use the command line heavily along with all the standard utilities and services that came with your distribution. At lot has changed since then, and nowadays, you can use a standard Linux desktop without ever having to open a terminal or use old UNIX services. Even as a sysadmin, these days, you often are a few layers of abstraction above some of these core services.

Automate Sysadmin Tasks with Python's os.walk Function

Using Python's os.walk function to walk through a tree of files and directories. I'm a web guy; I put together my first site in early 1993. And so, when I started to do Python training, I assumed that most of my students also were going to be web developers or aspiring web developers. Nothing could be further from the truth. Although some of my students certainly are interested in web applications, the majority of them are software engineers, testers, data scientists and system administrators.

Normalizing Filenames and Data with Bash

URLify: convert letter sequences into safe URLs with hex equivalents. This is my 155th column. That means I've been writing for Linux Journal for: $ echo "155/12" | bc 12 No, wait, that's not right. Let's try that again: