Skip to main content

Posts

Showing posts with the label CLI

Exploring CLI: Better Bash Scripts with Bashly Part 3

  This will be the last article I do on bash scripting for now. I want to shift gears for a few and explore some other languages. This project is called 'rmspaces'. It's another simple little program created with bash and Bashly for removing the spaces in filenames. It's super simple and does something super simple but useful. Yet, as simple as it may have seemed, I actually had a little trouble building this one that I will get into soon. Just as with the last two articles, I used  Bashly  to generate the finished script. The following bit I was able to re-use from the previous script. It checks for input being piped or redirected to stdin and if that is empty then it will parse the command line and separate multiple files passed as a comma separated list or a single item and assigns it to an array: The meat of the work is the part after that where the script splits the filename from its extension then after changing that string puts it back together with the modified ...

Exploring CLI: Better Bash Scripts with Bashly Part 2

  I enjoyed the srcset project so much that I want to create a set of scripts for creating and managing my projects. In recent Linux news it's been said that the home directory will have a Projects folder by default. I have always created this folder anyway and the scripts I will be creating assume this path exists or will create it if it doesn't. This post will spotlight the new-website command. Just as with the last article, I used Bashly  to generate the finished script. To recap what I said in the first part of this series, I aim for my scripts to follow some basic guidelines when possible and ideal: a command does one thing and does it well a command should be able to accept data from pipe The new-website script, like the previous srcset project, is simple. I bounce back and forth between different project directory structures for websites and I am aiming to try and stick to one convention and have some uniformity (writing this I am thinking of changing it already in the ...

Exploring CLI: Better Bash Scripts With Bashly Part 1

The main reason I prefer Unix/Linux over Windows operating systems is the terminal. Nix terminal shells just feel cleaner and organized to me than that of CMD or PowerShell. I won't claim to be an all knowing expert on the subject, I can only speak on what I've experienced, but the preference is 95% based on the feel of it overall. The Unix CLI philosophy and POSIX standards provide us with a powerful and versatile tool with simple commands that each do one thing and do it well. Spend some time typing out some PowerShell 'one-liners' then jump in a Nix terminal and I am willing to bet you will at least understand. Bash has been around a long time with version 0.99 being released in 1989. It's mature, programmable and versatile. Bash is the default shell of many popular linux distributions and used to be the default for Mac  OS before the switch to zsh. Some common commands we use are actually shell scripts (e.g gunzip, ldd and which). I am not a Bash programming exp...