Article 5PRE2 Command line wizardry, part two: Variables and loops in Bash

Command line wizardry, part two: Variables and loops in Bash

by
Jim Salter
from Ars Technica - All content on (#5PRE2)
virtual-play-date-ideas-magic-tricks-158

Enlarge / Getting the hang of iteratively building commands interactively is all it really takes to become a command line wizard. (credit: Bashar Shglila / Getty Images)

In our first tutorial on command line wizardry, we covered simple redirection and the basics of sed, awk, and grep. Today, we're going to introduce the concepts of simple variable substitution and loops-again, with a specific focus on the Bash command line itself, rather than Bash scripting.

If you need to write a script for repeated use-particularly one with significant logical branching and evaluation-I strongly recommend a "real language" instead of Bash. Luckily, there are plenty of options. I'm personally a big fan of Perl, in part because it's available on pretty much any *nix system you'll ever encounter. Others might reasonably choose, say, Python or Go instead, and I wouldn't judge.

The real point is that we're focusing on the command line itself. Everything below is something you can easily learn to think in and use in real time with a little practice.

Read 47 remaining paragraphs | Comments

index?i=b2rmK2aRxcs:in0f0CJZwD8:V_sGLiPB index?i=b2rmK2aRxcs:in0f0CJZwD8:F7zBnMyn index?d=qj6IDK7rITs index?d=yIl2AUoC8zA
External Content
Source RSS or Atom Feed
Feed Location http://feeds.arstechnica.com/arstechnica/index
Feed Title Ars Technica - All content
Feed Link https://arstechnica.com/
Reply 0 comments