Tag: Shell Script
-
Linux distro conditionals in shell script
It’s happening again. I’ve grown a bit tired of Debian, and have started to long for all the bleeding edge glory that is Arch. As this is a semi-frequent occurrence in my life, I’ve gotten pretty good at juggling distributions within my shell scripts, specifically in my dotfiles. Since each…
-
Parsing arguments in shell script
I write a good amount of shell scripts, but I tend to use arguments pretty sparingly. Because of this, my implementation to handle said arguments tends to be pretty weak. Some good examples are the arguments needing to be passed in a specific order and a lack of using long…
-
Wait for open port before running command
There comes a time in every software engineer’s life, when they need to run a command, but only after a port has been opened by a completely separate process. Sure, you could sit around and wait for the port to open up before running your command, but what’s the fun…
-
Associative arrays in Bash
Arrays, both indexed and associative are a powerful and versatile data type, regardless of the language you’re utilizing them in. At one point in Bash’s history, pre-version 4.0, Bash only had indexed arrays. These indexed arrays were defined as such: # Initialize an array with values arr=(“first” “second” “third”) #…
-
Case statements in shell script
While I do love the command-line, and will throw shell script at most problems if it’s the right tool for the job, it’s actually fairly rare that I write case statements. Generally speaking, my shell scripts will usually interrogate a variable or two, never too crazy or anything. With that,…
-
Delete all files in an S3 bucket
Last year I had sunset a project that was using both AWS’ S3 and Linode’s S3-compatible object storage offering. After pulling down some final snapshots, I wanted to delete the buckets on both services. Similar to the error you receive when you attempt to rmdir a directory with files in…
-
Looping through an array in shell script
Generally speaking, when I need to work with an array or dictionary type of variable, I tend to reach for something other than Bash / shell scripting. This primarily stems from the fact that Bash didn’t support arrays until version 4.x and when I first learned about them, macOS (then…
-
Splitting a string into two variables
Even though the command-line is like my second home, I still fall short in terms of being able to some basic things. This is primarily because they just don’t come up that often so when I do figure out how to do it, I just don’t retain what I’ve learned….
-
Complete CI/CD pipeline with GitLab Runners
Automation is one of the best ways to improve productivity. Even as a development team of one, spending a bit of time on DevOps and improving your developer quality of life can pay off immensely. Automated tasks strip away cognitive load. No more forgetting to deploy code because the process…
-
Finding which process is listening on a port
I’m known for having a lot of projects. These days I have a day job, am trying to grind out more posts a week on this blog, regularly write for Alligator.io, run HolidayAPI and Ginpop and am currently on the “advisor track” for Startup School with CrowdSync. This list doesn’t…