Skip to main content

LHB Linux Digest #26.16: Bash Arrays, mapfile, Self-hosted Linear Alternative and More

One variable, many values.

ยท By Abhishek Prakash ยท 5 min read

Warp Terminal

It's a short edition, but a timely one.

If you have an OpenCode Console account, jump to the news section first. A breach there may have exposed third-party API keys, and rotating yours now is cheap insurance.

Also, the Linux Foundation security certification sale I mentioned last week ends in a few hours. If you were on the fence, this is your last chance.

On the learning side, it's Bash arrays this week, plus a neat way to fill one straight from a command with mapfile.

Also, I have revamped the courses page so that you can have a better understanding of where to start learning.

๐Ÿงต One variable, many values

Most scripts start with plain variables. Then one day you need to hold a list of files, servers or usernames, and you end up with file1, file2, file3. That's when you need arrays.

servers=("web01" "web02" "db01")
echo "${servers[0]}"      # first element
echo "${#servers[@]}"     # number of elements
servers+=("cache01")      # append one more element

Indexing starts at 0, and the curly braces are essential. Otherwise echo $servers[0] will print web01[0], which is not what you would want.

The common confusing part is quoting. Always loop over "${servers[@]}" with the double quotes. It expands each element as its own word, so an item like my file.txt stays in one piece. Drop the quotes and Bash splits it into my and file.txt. Use "${servers[*]}" instead and you get everything together into a single string.

You can also take a slice. "${servers[@]:1:2}" gives you two elements starting from index 1.

When numbers don't make sense as keys, use an associative array. It maps names to values, like a dictionary:

declare -A port=([ssh]=22 [http]=80 [https]=443)
echo "${port[https]}" #outputs 443

So how do you fill an array with the output of a command? That's this week's tip.

๐Ÿ’ก Quick terminal tip

The mapfile command lets you load command output directly into an array, no ugly while read loop needed. For example.

mapfile -t files < <(find . -name "*.log")

The above command searches the current directory (.) and all subdirectories for files ending in .log. And stores their paths as elements of the Bash array files.

Now, you can access each result as files[0], files[1], etc.

echo "${files[0]}"

โŒ› Last call: security certifications at 40% off

Linux Foundation cybersecurity sale

Quick reminder from last week. The Linux Foundation's Cybersecurity Awareness Month sale ends today, 23rd October at 23:59 UTC.

If you manage servers, containers or pipelines, you're expected to know how to lock them down. A certification is how you prove it to someone who's hiring.

The CKS (Certified Kubernetes Security Specialist) is the obvious pick if you work with Kubernetes. You can bundle the KCSA (Kubernetes and Cloud Native Security Associate) and CKS exams for $387 instead of $645.

You get two exam attempts within 12 months, so you only need to buy today. Prepare over the next few months and sit the exam when you're ready.

๐Ÿ“ฆ Self-hosting: itsaplan

itsaplan is an open-source, self-hosted project management platform designed for teams that work alongside AI agents. It combines issue tracking, planning, and collaboration features in a familiar Linear-style interface while keeping data under your control.

GitHub - croffasia/itsaplan: โญ๏ธโญ๏ธโญ๏ธ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
โญ๏ธโญ๏ธโญ๏ธ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products. - croffasia/itsaplan

๐Ÿ› ๏ธ Tool discovery: lazyenv

lazyenv is a terminal-based interface for viewing, editing, and managing .env files without manually scrolling through text files. It simplifies working with environment variables across local development, containers, and deployment workflows.

GitHub - lazynop/lazyenv: TUI for managing .env files
TUI for managing .env files. Contribute to lazynop/lazyenv development by creating an account on GitHub.

๐Ÿ“ฐ Linux news that matters

๐Ÿ˜‚ Geek humor

๐Ÿ’Œ Keep on loving Linux Handbook

There is an AWS video course in works. It should be with you by Halloween ๐ŸŽƒ

Become a Pro member ยท Browse courses ยท eBooks

Missed the previous editions? You can access the newsletter archives.

I like reading your messages, so just hit reply and tell me how you are enjoying Linux ๐Ÿ˜„

About the author

Abhishek Prakash Abhishek Prakash
Updated on Oct 23, 2026