June 28th, 2024

Advanced Bash-Scripting Guide

The Advanced Bash-Scripting Guide by Mendel Cooper is a comprehensive resource covering shell scripting from basics to advanced topics. It includes exercises, examples, and practical insights for self-study and reference.

Read original articleLink Icon
Advanced Bash-Scripting Guide

The Advanced Bash-Scripting Guide by Mendel Cooper is a comprehensive resource for learning shell scripting from beginner to advanced levels. It covers topics such as special characters, variables, loops, command substitution, functions, arrays, debugging, and more. The guide includes exercises and examples to facilitate active learning. Suitable for self-study, classroom use, and reference, it aims to impart UNIX® wisdom and scripting techniques. Released to the Public Domain with no copyright restrictions, the guide is dedicated to Anita. The table of contents outlines the structure of the guide, including sections on basics, commands, advanced topics, and a bibliography of contributed scripts and reference cards. With a focus on practical application and hands-on experience, the guide serves as a valuable tool for anyone looking to enhance their shell scripting skills.

Link Icon 7 comments
By @mmh0000 - 5 months
There are many foot-guns to be found in bash scripting.

I highly recommend the Wooledge wiki for any and all bash knowledge, it points every place you can go wrong, especially when using advanced features.

https://mywiki.wooledge.org/FullBashGuide

http://mywiki.wooledge.org/BashFAQ

By @freedomben - 5 months
Really great resource. If you want more of a book format, I also highly recommend The Linux Command Line by William Shotts: https://linuxcommand.org/tlcl.php
By @TacticalCoder - 5 months
Mandatory comment every time the subject comes up: shellcheck is really helpful when writing Bash scripts.

shellcheck itself is not written in Bash (it's written in Haskell) but it gives really good hints and find lots of bugs. If you disagree with some of its warnings, you can choose which ones you want to turn off.

I use it from within Emacs and it works fine. Set that thing once, years ago, and it's been helping me ever since.

Also: shellcheck probably ships with your Linux distro.

By @systems - 5 months
last update 2014

that being said, it think 10 years later, linux should pick a data oriented shell (powershell or nushell) and go full in on it

on windows, almost all services have some Powershell support

i understand that on linux, command line support is always there, so unlike windows adding command line support is not really news, but still i think the move to a data oriented shell, is better

By @Grimeton - 5 months
There are so many things that can go wrong when scripting in the shell. If you don't sit down and play with it, trying to understand what's going on, then no guide will save you.

    : "${foo:=bar}"
By @KolenCh - 5 months
I used to read this cover to cover when I first learnt bash. But I later found that its advice can be subpar from time to time. There are better resources in learning bash.