Fun with Bash shell scripting

Now that I’ve got a couple skills in shell scripting, what have I been doing with my new found knowledge?

In almost every case I’ve started by creating a UI in Keyboard Maestro, then I pass variables to the shell script and it does the work. In some cases that’s the value for the loop, in others, its multiple text field entries.

I tell you what, using Keyboard Maestro and the Shell together is one of the reasons the Mac is so damn power and productive.

So far I’ve worked:

- Index a drive using find "$PWD"
- Inventory Tracker for D2
    - Create a csv file with the loot information
    - Create a reader to search if I already have an item
    - Remove an item from the csv file
    - Transfer the loot to another character
    - Yes, I could use a spreadsheet, but there is no learning in that, and this will run and be done faster than a spreadsheet could even start up.
    - A fellow I used to work with once said, if you have awk, grep, and sed, you have a database. I see exactly what he means.
- Password generator
    - Random text string including special characters
    - Password made of words from text files
    - There are tools that do this, but it was fun to learn
- Name generator using two files
    - Create names for a story or D2 character
    - Similar to the password generator
    - It's silly, but it's fun
- Site specific browser creation
    - Enter the name of the browser app, everything else is done for me

I find Keyboard Maestro and Bash a really good combination. I can make a UI with text fields, drop downs, or directory pickers, then pass that information to the shell script.

I can use a UI from Keyboard Maestro to prompt for text to search through text files and finish the job before a Terminal prompt is even open.

Keyboard Maestro generates a random number of passwords of whatever length I choose faster than a password manager can open.

Whenever I need to pick a password for work or a website, the job is done as soon as I’m done thinking about changing it. I’ve got a dozen passwords to choose from.

These aren’t necessarily complicated tasks, but the commands used are the building blocks for other scripts. It’s the same thing I experienced with Web Automation, once you get a few things done, 80% of all your other tasks build on that established code base.

I also realize opening a spreadsheet or password manager on M3+ technology would be a totally different experience, but I’m not there yet.

When I want to work on something new, my first stop is to ask AI. Sites like StackOverflow are awesome and there are some amazingly smart people posting answers up there, but not all their answers make sense, nor do they address my particular scenario. Not to mention I need the exact search term to bring up the right answer.

I can look to AI and explain my specific scenario, such as:

Can you help me create a macOS compatible Bash shell script that does the following:

  • I have a text file called files_to_delete.txt
  • Each line in files_to_delete.txt is a filename such as:
    ~/Documents/900_1000.jpg
    ~/Documents/900_1261.jpg
    ~/Documents/900_1092.jpg
    ~/Documents/900_1291.jpg
  • I want to delete file listed in the text file
  • What is the correct syntax to read each line and delete the file?

I can then mold and shape that script to my liking.

Keyboard Maestro is a great automation tool, but when you combine it with Bash, you extend that power many times over.

If you’ve come as an elf, see it through as an elf.
Author Signature for Posts
0